Web applications and JSP. Carl Nettelblad

Size: px
Start display at page:

Download "Web applications and JSP. Carl Nettelblad"

Transcription

1 Web applications and JSP Carl Nettelblad

2 Outline Review and assignment Jara Server Pages Web application structure

3 Review We send repeated requests using HTTP Each request asks for a specific file/resource Request contains a path, possibly including a query string, headers and (possibly) a request body A request gives a response with headers and body (content) Important verbs: GET and POST Your browser will switch between them Client HTTP Request Server HTTP Response

4 URLs Protocol Domain Port number (optional) Path Query string (optional) Anchor (only on the client, optional)

5 HTML and CSS HTML is a text-based format Plain text enclosed in tags with a specific structure Each tag <h1> </h1> can have attributes <h1 class="myclass"> Formatting can be controlled by CSS Separate files with rules on the form selector {declaration;} h1 {font-size: 30px;}.myclass {text-decoration: overline; color: blue;} #sometagid {background-color: #00ff00;} h1.myclass {visibility:hidden;}

6 Servlets Single instance serving requests to a part of the web application Configured using annotations or web.xml What paths are served by this servlet init, service, destroy service calls doget, dopost init similar to constructor, but full configuration ready Contexts Request, session, config, servlet context Parameters and attributes

7 Forwarding and filters RequestDispatcher can be used to find the handler for another URL Process a complex action Render a simple view Filters can be used to provide common processing for all parts of an application Security Logging Establish standard objects in contexts

8 Assignment details Memos for both assignments will be online on or before April 5 Assignment 1 A web application containing Purpose: At least one servlet At least one JSP page Some interaction between the servlet and the JSP Some interaction between the components and the user(s) Responses changing depending on user actions Getting familiar with the environment and the technologies The hard part is understanding the architecture, not the programming

9 Execution Done in groups 25 slots in the Student Portal ~60 people taking the course Groups of 2-3 people Make sure that you have a group Enroll in the Student Portal, Project group division

10 Groups Identical group for all parts of the course Groups will be fully locked after lecture April 13 Groups with fewer than 3 people might be asked to take on an extra member Don t join a group yourself without contacting the existing members first

11 Assignment reporting Upload the code in the Student Portal after April 13 (when groups are finalized), before the lab on April 23 All group members should be present during the lab Can be asked questions about the assignment or the structure around it An approximate schedule for reporting during the lab will be posted (which groups presents to whom, when)

12 Don t forget the forums Student portal forums Feedback or comments on lectures Questions regarding the assignments/software issues Forum to find project partners

13 Java Server Pages Presentation framework Native part of the Java EE standard Presentation based on HTML

14 Different paradigms Servlet-like model Give the request to a piece of code Render the full response Also the model for Common Gateway Interface (CGI) many early interactive web pages were Perl scripts using CGI Template/inline model Static and dynamic content handled in a similar way Seamless transition between a fully static page and a page with some interaction Microsoft ASP, JSP, PHP

15 The basic conflict Java is an imperative language How do I want something to happen HTML is a declarative language What do I want to happen Java code generating HTML can easily get ugly Mixing the two is kind of tricky Simple as what is the basis for indentation

16 What is a JSP, really? A normal Java class is compiled from source to a Java.class file A JSP page is compiled from JSP source to a Java class file Specifically a servlet extending HttpServlet A rather tedious service method that emits the full page The container is responsible to recompile on the fly Netbeans and Glassfish accomplished this together in our demo for servlets

17 JSP building blocks HTML JSP-specific tags and tag libraries Expression Language expressions Scriptlets JSP pages and JSP documents A more standardized XML syntax in JSP documents We are showing the JSP page syntax here

18 Scriptlets <html> <body> <% out.print("welcome to jsp"); %> </body> </html> Any Java code can go into <% %> tags Ends up inside the service method, in the proper place If all logic is done like this, it s just as hard to read as a separate servlet

19 Expression tags <html> <body> <%= "welcome to jsp" %> </body> </html> <%= request.getattribute("tb") %> Any Java expression that can evaluate to a string Note, no semicolon

20 Declaration tags <html> <body> <%! int data = 50; int square(int n){ return n*n; } %> <%= "Square of 50 is:"+square(data) %> </body> </html> <%! %> is used for class-level declarations of methods or variables Remember what we said about instance variables in servlets Shared among all requests If you find that you need to use separate methods in your JSP, your JSP is probably getting too complex But it s still better than cut n paste spaghetti of the same code over and over

21 Special objects request response config application ServletContext pagecontext wrapper to access all contexts with common methods page holds a reference to the hidden servlet, but of Object type out output writer exception only used in special error pages, exception that caused the error page to be shown

22 Page directive Common control of all code in a single JSP page Several options not used that frequently Some are more important

23 Page import Equivalent to import in Java Needed to avoid fully qualified names for types page import="java.util.date" %>

24 Page errorpage Any uncaught exception occurring on the page results in the specified error page being loaded instead page errorpage="showerror.jsp" %> Showing good errors is important for the user experience Showing too much information in errors to the user can constitute a security risk

25 Page contenttype The content type sent in the HTTP response headers page contenttype="text/html" %> Showing good errors is important for the user experience Showing too much information in errors to the user can constitute a security risk

26 Include directive You can include another source file Useful to always have a similar menu/header <%@include file="somefile.ext"> Also the taglib directive, more about that later

27 Action elements Replacement for the native JSP syntax <% in JSP documents Some specific actions <jsp:usebean> <jsp:setproperty> <jsp:getproperty> <jsp:forward> <jsp:include>

28 Use a bean Get or create a bean with a specific name from a specific context (page, request, session, application) Made available with just that name as a variable in the rest of the code Code inside tag only included if bean not already found, but created anew <jsp:usebean id="tb" scope="request" class="testbean"> Bean was created, should have been found in request </jsp:usebean>

29 Set a property Change a single value in a variable <jsp:setproperty name="tb" property="name" value="carl" /> Change all fields that match parameter values in the request <jsp:setproperty name="tb" property="*" /> Be careful, the user can add any parameters Imagine having a user bean with a method setpassword, not too good

30 Get a property Get a property from a bean and write that in the response <jsp:getproperty name="tb" property="name" /> Simpler (?) equivalent <%= tb.name %>

31 Forward a request Similar to servlets, a request can be forwarded to another JSP or servlet With additional parameters, if you want to <jsp:forward page="anotherpage.jsp"> <jsp:param name="name" value="carl" /> </jsp:forward>

32 More on forwarding No part of the existing page is sent to the client If data has already been transmitted, forwarding is not allowed Settings like buffer sizes and flushing can determine this The destination can be controlled by JSP code like <%= someurlvariable %>

33 Inclusion JSP files can be included <jsp:include page="/another/page.html" /> Parameters allowed here as well Different from > The include directive is done at compile time, file source must be fixed All variables are shared between original and included file The include action is done at execution, path can be determined dynamically

34 Expression language Java code is cumbersome Get attributes with.getattribute("attributename"), or.getattributename(), etc Type casts to the correct class Page author needs to know what kind of Java object is this Java code is too flexible Logic structure can get complex Calling methods causing changes, rather than just looking

35 Structure of an expression ${1 + 3} Equivalent to <%= %> ${sessionscope.cart.nitems} or even ${cart.nitems} Equivalent to <%= ((SomeCartClass) session.getattribute("cart").getnitems() %> or: <jsp:usebean id="cart" scope="session" class="somecartclass" /> <%= cart.getnitems() %> If and only if you have the right page imports Syntax for deferred evaluation #{} instead More about this in JSF and JSTL lectures

36 Implicit objects pagecontext param all page parameter paramvalues all page parameters as arrays (a query string can containg param1=value1&param1=value2 ) header headervalues cookie initparam

37 And the scopes pagescope requestscope sessionscope applicationscope In Java, you need to access the contexts explicitly In EL, the contexts work as real scopes ${somevar} will look for the somevar attribute in the page scope, the request scope, the session scope, and the application scope, in order ${applicationscope.somevar} only necessary if the name is used in multiple places

38 Note about the page scope Attributes in the page context are not the same thing as variables in JSP <% int x = 42; %> ${x} Does not work! Instead: <% pagecontext.setattribute("x", 42); %> ${x}

39 The lifetime of the scopes Request all the processing of this request (remains during forwarding) Page the processing of this page (remains with >, not <jsp:include>) Session the processing of all requests coming from the same user session Application as long as the application is loaded (not redeployed), common to all servlets and JSPs in it Identical for servlets, JSPs and EL

40 EL is not Java No loops No if statements Trinary operator works: condition? value-if-true : value-if-false a < b? a : b gives the smallest value of a or b Different scopes Maps and get methods are accessed with a field-like syntax Special names in maps can be accessed with ['field-name'] brackets String literals can be written using " " or '

41 Back to our servlet example // check if we have a parameter called action // if so, check its value if(request.getparameter("action")!= null && request.getparameter("action").equals("show")) { // create a bean object and populate it TestBean tb = new TestBean(); tb.setage(new Integer("32")); tb.setname("fredrik"); // get a dispatcher and forward the request // store the bean object in the session context first RequestDispatcher rd = request.getrequestdispatcher("test.jsp"); request.setattribute("tb", tb); request.setattribute("date", new java.util.date()); rd.forward(request, response); } else { // if the condition above failed, forward the // request to another JSP } RequestDispatcher rd = request.getrequestdispatcher("error.jsp"); rd.forward(request, response);

42 Plain JSP version of test.jsp <html><head> </head> <meta http-equiv="content-type" content="text/html; charset=windows-1252"> <title>hello World</title> <body> <h2>the current time is: </h2> <p> <%= new java.util.date() %></p> <jsp:usebean id="tb" scope="request" class="testbean"> Error, the instance is created in the bean </jsp:usebean> <H1> <jsp:getproperty name="tb" property="name" /> </H1> <%= tb.getname() %> <br> <jsp:usebean id="date" scope="request" class="java.util.date"/> <%= date %> </body></html>

43 EL version of test.jsp <html><head> </head> <meta http-equiv="content-type" content="text/html; charset=windows-1252"> <title>hello World</title> <body> <h2>the current time is: </h2> <p> EL CAN T CREATE NEW OBJECTS </p> <h1> ${tb.name} </h1> ${tb.name} <br> ${date} </body></html>

44 A comment about comments HTML comments <!-- --!> Part of the HTML standard, transmitted to the client Don t put secrets there A true JSP comment <%-- --%> Only on the server Inside scriptlets (Java code), normal Java comments work /* */, //

45 Rule of thumb If you are using JSP Try to express what you can using tags and EL JSTL adds more tags You can write your own specific tag libraries More complex logic should go into servlets, populating the contexts Most serious drawbacks of JSP Hard to modularize rendering of complex UI components Yet, different enough from HTML to just open and test layout in a browser

46 Alternatives to JSP Java Server Faces Java EE technology for rendering user interfaces and complex applications A step further away from directly doing HTML, but still declarative Other examples Apache Wicket, Apache Tapestry More modern templating systems tries to respect HTML more Examples have been Freemarker, Apache Velocity, Thymeleaf Tends to come and go Templates which render well without the server are practical for client-heavy applications

47 The web application archive An extended JAR (a zip file with a specific structure) Static content and JSP files in the root Open section Special directories META-INF, for any JAR file (including a web application WAR) WEB-INF Servlets, configuration, property files Closed section

48 Inside of WEB-INF Files directly web.xml Other configuration files Directory classes Java class files for servlets, beans etc Directory lib Archives with dependencies (jar files used by our code) Other property and configuration files in other directories as well

49 Example ls -R error.jsp test.jsp test.xsl WEB-INF./WEB-INF: classes c.tld lib src web.xml x.tld./web-inf/classes: mypackage./web-inf/classes/mypackage: TestBean.class TestServlet.class./WEB-INF/lib: jstl.jar standard.jar./web-inf/src: mypackage./web-inf/src/mypackage: TestBean.java TestServlet.java

50 The role of the IDE An IDE or a build system will create the full WAR It s very unreliable to copy the right files to the subdirectories manually

51 web.xml Used to be crucial for configuration Example content: Initialization and global context parameters Servlet mappings Filter mappings Tag lib definitions Authorization declarations Authentication details Most of this can now be controlled by annotations All configuration in one place vs. configuration close to the code

52 web.xml example <?xml version = '1.0' encoding = 'UTF-8'?> <web-app xmlns=" xmlns:xsi=" xsi:schemalocation = " version="3.0" > <context-param> <param-name>dbname</param-name> <param-value>itdb</param-value> </context-param>

53 web.xml example <servlet> <servlet-name> 6. servlet </servlet-name> <servlet-class> 6. servlet </servlet-class> <init-param> <param-name> filename </param-name> <param-value>../webapps/murach/user .txt </param-value> </init-param> </servlet> </web-app>

54 Servlet mapping Adding specific URL patterns for a servlet <servlet-mapping> <servlet-name> 6. servlet </servlet-name> <url-pattern> /myservlet </url-pattern> </servlet-mapping>

55 Defining init parameters Context parameters go into ServletContext, common to all the application Init parameters specific to the servlet <servlet> </servlet> <servlet-name>a Servlet</servlet-name> <servlet-class>com.controller.testservlet</servlet-class> <init-param> </init-param> <description>this is an init parameter example</description> <param-name>initparam</param-name> <param-value>init param value</param-value> Accessible in init method in servlet (hence the name)

56 Lifetime of sessions <session-config> <session-timeout> 30 </session-timeout> </session-config> Sessions time out Security: don t let another user use an unattended computer Server resources: saving tens of thousands of stale sessions is expensive

57 Mappings for static content The HTTP client is supposed to look at Content-Type header, not file extension The WAR doesn t contain content type information for static files So, the server needs to know what type to state for different extensions (defaults might be sensible) <mime-mapping> <extension> html </extension> <mime-type> text/html </mime-type> </mime-mapping>

58 Start page Index page, welcome page What page to show if the user just puts /application/ as the URL <welcome-file-list> <welcome-file> index.jsp </welcome-file> <welcome-file> index.html </welcome-file> </welcome-file-list>

59 Common error handling <error-page> <exception-type> java.lang.throwable </exception-type> <location> / 6/error.html </location> </error-page>

60 Specific errors <error-page> <exception-type> java.lang.ioexception </exception-type> <location> / 6/ioerror.html </location> </error-page>

61 HTTP errors <error-page> <error-code> 404 </error-code> <location> / 6/filenotfound.html </location> </error-page>

62 Summarizing JSP is powerful Transformed into a servlet behind the scenes The full power of Java Try to avoid using that power Much can be accomplished with just Expression Language (EL), HTML and (later) custom tags This will be easier to maintain More similar to other modern templating engines

Structure of a webapplication

Structure of a webapplication Structure of a webapplication Catalogue structure: / The root of a web application. This directory holds things that are directly available to the client. HTML-files, JSP s, style sheets etc The root is

More information

Servlets. An extension of a web server runs inside a servlet container

Servlets. An extension of a web server runs inside a servlet container Servlets What is a servlet? An extension of a web server runs inside a servlet container A Java class derived from the HttpServlet class A controller in webapplications captures requests can forward requests

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Java Server Pages (JSP) Dr. Basem Suleiman Service Oriented Computing Group, CSE, UNSW Australia Semester 1, 2016, Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2442

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2411 1 Review:

More information

Fast Track to Java EE 5 with Servlets, JSP & JDBC

Fast Track to Java EE 5 with Servlets, JSP & JDBC Duration: 5 days Description Java Enterprise Edition (Java EE 5) is a powerful platform for building web applications. The Java EE platform offers all the advantages of developing in Java plus a comprehensive

More information

Session 21. Expression Languages. Reading. Java EE 7 Chapter 9 in the Tutorial. Session 21 Expression Languages 11/7/ Robert Kelly,

Session 21. Expression Languages. Reading. Java EE 7 Chapter 9 in the Tutorial. Session 21 Expression Languages 11/7/ Robert Kelly, Session 21 Expression Languages 1 Reading Java EE 7 Chapter 9 in the Tutorial 2 11/7/2018 1 Lecture Objectives Understand how Expression Languages can simplify the integration of data with a view Know

More information

PES INSTITUTE OF TECHNOLOGY, SOUTH CAMPUS DEPARTMENT OF MCA INTERNAL TEST (SCHEME AND SOLUTION) II

PES INSTITUTE OF TECHNOLOGY, SOUTH CAMPUS DEPARTMENT OF MCA INTERNAL TEST (SCHEME AND SOLUTION) II PES INSTITUTE OF TECHNOLOGY, SOUTH CAMPUS DEPARTMENT OF MCA INTERNAL TEST (SCHEME AND SOLUTION) II Subject Name: Advanced JAVA programming Subject Code: 13MCA42 Time: 11:30-01:00PM Max.Marks: 50M ----------------------------------------------------------------------------------------------------------------

More information

This course is intended for Java programmers who wish to write programs using many of the advanced Java features.

This course is intended for Java programmers who wish to write programs using many of the advanced Java features. COURSE DESCRIPTION: Advanced Java is a comprehensive study of many advanced Java topics. These include assertions, collection classes, searching and sorting, regular expressions, logging, bit manipulation,

More information

Session 11. Expression Language (EL) Reading

Session 11. Expression Language (EL) Reading Session 11 Expression Language (EL) 1 Reading Reading Head First pages 368-401 Sun Java EE 5 Chapter 5 in the Tutorial java.sun.com/javaee/5/docs/tutorial/doc/javaeetutorial.pdf / / / / / Reference JSTL

More information

Unit 5 JSP (Java Server Pages)

Unit 5 JSP (Java Server Pages) Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic, platform-independent method for building Web-based applications. It focuses more on presentation logic

More information

Java Server Pages, JSP

Java Server Pages, JSP Java Server Pages, JSP Java server pages is a technology for developing web pages that include dynamic content. A JSP page can change its content based on variable items, identity of the user, the browsers

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Semester 2, 2017 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2465 1 Review:

More information

Java Server Pages. JSP Part II

Java Server Pages. JSP Part II Java Server Pages JSP Part II Agenda Actions Beans JSP & JDBC MVC 2 Components Scripting Elements Directives Implicit Objects Actions 3 Actions Actions are XML-syntax tags used to control the servlet engine

More information

112. Introduction to JSP

112. Introduction to JSP 112. Introduction to JSP Version 2.0.2 This two-day module introduces JavaServer Pages, or JSP, which is the standard means of authoring dynamic content for Web applications under the Java Enterprise platform.

More information

JavaServer Pages (JSP)

JavaServer Pages (JSP) JavaServer Pages (JSP) The Context The Presentation Layer of a Web App the graphical (web) user interface frequent design changes usually, dynamically generated HTML pages Should we use servlets? No difficult

More information

A Gentle Introduction to Java Server Pages

A Gentle Introduction to Java Server Pages A Gentle Introduction to Java Server Pages John Selmys Seneca College July 2010 What is JSP? Tool for developing dynamic web pages developed by SUN (now Oracle) High-level abstraction of Java Servlets

More information

web.xml Deployment Descriptor Elements

web.xml Deployment Descriptor Elements APPENDIX A web.xml Deployment Descriptor s The following sections describe the deployment descriptor elements defined in the web.xml schema under the root element . With Java EE annotations, the

More information

112-WL. Introduction to JSP with WebLogic

112-WL. Introduction to JSP with WebLogic Version 10.3.0 This two-day module introduces JavaServer Pages, or JSP, which is the standard means of authoring dynamic content for Web applications under the Java Enterprise platform. The module begins

More information

Unit 4 Java Server Pages

Unit 4 Java Server Pages Q1. List and Explain various stages of JSP life cycle. Briefly give the function of each phase. Ans. 1. A JSP life cycle can be defined as the entire process from its creation till the destruction. 2.

More information

1. Introduction. 2. Life Cycle Why JSP is preferred over Servlets? 2.1. Translation. Java Server Pages (JSP) THETOPPERSWAY.

1. Introduction. 2. Life Cycle Why JSP is preferred over Servlets? 2.1. Translation. Java Server Pages (JSP) THETOPPERSWAY. 1. Introduction Java Server Pages (JSP) THETOPPERSWAY.COM Java Server Pages (JSP) is used for creating dynamic web pages. Java code can be inserted in HTML pages by using JSP tags. The tags are used for

More information

JavaServer Pages. What is JavaServer Pages?

JavaServer Pages. What is JavaServer Pages? JavaServer Pages SWE 642, Fall 2008 Nick Duan What is JavaServer Pages? JSP is a server-side scripting language in Java for constructing dynamic web pages based on Java Servlet, specifically it contains

More information

Fast Track to Java EE

Fast Track to Java EE Java Enterprise Edition is a powerful platform for building web applications. This platform offers all the advantages of developing in Java plus a comprehensive suite of server-side technologies. This

More information

Introduction to JSP and Servlets Training 5-days

Introduction to JSP and Servlets Training 5-days QWERTYUIOP{ Introduction to JSP and Servlets Training 5-days Introduction to JSP and Servlets training course develops skills in JavaServer Pages, or JSP, which is the standard means of authoring dynamic

More information

Server-side Web Programming

Server-side Web Programming Server-side Web Programming Lecture 20: The JSP Expression Language (EL) Advantages of EL EL has more elegant and compact syntax than standard JSP tags EL lets you access nested properties EL let you access

More information

About the Authors. Who Should Read This Book. How This Book Is Organized

About the Authors. Who Should Read This Book. How This Book Is Organized Acknowledgments p. XXIII About the Authors p. xxiv Introduction p. XXV Who Should Read This Book p. xxvii Volume 2 p. xxvii Distinctive Features p. xxviii How This Book Is Organized p. xxx Conventions

More information

CS506 Web Design & Development Final Term Solved MCQs with Reference

CS506 Web Design & Development Final Term Solved MCQs with Reference with Reference I am student in MCS (Virtual University of Pakistan). All the MCQs are solved by me. I followed the Moaaz pattern in Writing and Layout this document. Because many students are familiar

More information

JAVA 2 ENTERPRISE EDITION (J2EE)

JAVA 2 ENTERPRISE EDITION (J2EE) COURSE TITLE DETAILED SYLLABUS SR.NO JAVA 2 ENTERPRISE EDITION (J2EE) ADVANCE JAVA NAME OF CHAPTERS & DETAILS HOURS ALLOTTED SECTION (A) BASIC OF J2EE 1 FILE HANDLING Stream Reading and Creating file FileOutputStream,

More information

A.1 JSP A.2 JSP JSP JSP. MyDate.jsp page contenttype="text/html; charset=windows-31j" import="java.util.calendar" %>

A.1 JSP A.2 JSP JSP JSP. MyDate.jsp page contenttype=text/html; charset=windows-31j import=java.util.calendar %> A JSP A.1 JSP Servlet Java HTML JSP HTML Java ( HTML JSP ) JSP Servlet Servlet HTML JSP MyDate.jsp

More information

ADVANCED JAVA COURSE CURRICULUM

ADVANCED JAVA COURSE CURRICULUM ADVANCED JAVA COURSE CURRICULUM Index of Advanced Java Course Content : 1. Basics of Servlet 2. ServletRequest 3. Servlet Collaboration 4. ServletConfig 5. ServletContext 6. Attribute 7. Session Tracking

More information

Experiment No: Group B_2

Experiment No: Group B_2 Experiment No: Group B_2 R (2) N (5) Oral (3) Total (10) Dated Sign Problem Definition: A Web application for Concurrent implementation of ODD-EVEN SORT is to be designed using Real time Object Oriented

More information

More JSP. Advanced Topics in Java. Khalid Azim Mughal Version date: ATIJ More JSP 1/42

More JSP. Advanced Topics in Java. Khalid Azim Mughal   Version date: ATIJ More JSP 1/42 More JSP Advanced Topics in Java Khalid Azim Mughal khalid@ii.uib.no http://www.ii.uib.no/~khalid/atij/ Version date: 2006-09-04 ATIJ More JSP 1/42 Overview Including Resources in JSP Pages using the jsp:include

More information

Session 9. Introduction to Servlets. Lecture Objectives

Session 9. Introduction to Servlets. Lecture Objectives Session 9 Introduction to Servlets Lecture Objectives Understand the foundations for client/server Web interactions Understand the servlet life cycle 2 10/11/2018 1 Reading & Reference Reading Use the

More information

Session 8. Introduction to Servlets. Semester Project

Session 8. Introduction to Servlets. Semester Project Session 8 Introduction to Servlets 1 Semester Project Reverse engineer a version of the Oracle site You will be validating form fields with Ajax calls to a server You will use multiple formats for the

More information

Advance Java. Configuring and Getting Servlet Init Parameters per servlet

Advance Java. Configuring and Getting Servlet Init Parameters per servlet Advance Java Understanding Servlets What are Servlet Components? Web Application Architecture Two tier, three tier and N-tier Arch. Client and Server side Components and their relation Introduction to

More information

JSP - ACTIONS. There is only one syntax for the Action element, as it conforms to the XML standard:

JSP - ACTIONS. There is only one syntax for the Action element, as it conforms to the XML standard: http://www.tutorialspoint.com/jsp/jsp_actions.htm JSP - ACTIONS Copyright tutorialspoint.com JSP actions use constructs in XML syntax to control the behavior of the servlet engine. You can dynamically

More information

AN ISO 9001:2008 CERTIFIED COMPANY ADVANCED. Java TRAINING.

AN ISO 9001:2008 CERTIFIED COMPANY ADVANCED. Java TRAINING. AN ISO 9001:2008 CERTIFIED COMPANY ADVANCED Java TRAINING www.webliquids.com ABOUT US Who we are: WebLiquids is an ISO (9001:2008), Google, Microsoft Certified Advanced Web Educational Training Organisation.

More information

Java Server Page (JSP)

Java Server Page (JSP) Java Server Page (JSP) CS 4640 Programming Languages for Web Applications [Based in part on SWE432 and SWE632 materials by Jeff Offutt] [Robert W. Sebesta, Programming the World Wide Web] 1 Web Applications

More information

Advantage of JSP over Servlet

Advantage of JSP over Servlet JSP technology is used to create web application just like Servlet technology. It can be thought of as an extension to servlet because it provides more functionality than servlet such as expression language,

More information

DVS WEB INFOTECH DEVELOPMENT TRAINING RESEARCH CENTER

DVS WEB INFOTECH DEVELOPMENT TRAINING RESEARCH CENTER DVS WEB INFOTECH DEVELOPMENT TRAINING RESEARCH CENTER J2EE CURRICULUM Mob : +91-9024222000 Mob : +91-8561925707 Email : info@dvswebinfotech.com Email : hr@dvswebinfotech.com 48, Sultan Nagar,Near Under

More information

Specialized - Mastering JEE 7 Web Application Development

Specialized - Mastering JEE 7 Web Application Development Specialized - Mastering JEE 7 Web Application Development Code: Lengt h: URL: TT5100- JEE7 5 days View Online Mastering JEE 7 Web Application Development is a five-day hands-on JEE / Java EE training course

More information

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests What is the servlet? Servlet is a script, which resides and executes on server side, to create dynamic HTML. In servlet programming we will use java language. A servlet can handle multiple requests concurrently.

More information

LTBP INDUSTRIAL TRAINING INSTITUTE

LTBP INDUSTRIAL TRAINING INSTITUTE Java SE Introduction to Java JDK JRE Discussion of Java features and OOPS Concepts Installation of Netbeans IDE Datatypes primitive data types non-primitive data types Variable declaration Operators Control

More information

Session 8. Reading and Reference. en.wikipedia.org/wiki/list_of_http_headers. en.wikipedia.org/wiki/http_status_codes

Session 8. Reading and Reference. en.wikipedia.org/wiki/list_of_http_headers. en.wikipedia.org/wiki/http_status_codes Session 8 Deployment Descriptor 1 Reading Reading and Reference en.wikipedia.org/wiki/http Reference http headers en.wikipedia.org/wiki/list_of_http_headers http status codes en.wikipedia.org/wiki/_status_codes

More information

Java E-Commerce Martin Cooke,

Java E-Commerce Martin Cooke, Java E-Commerce Martin Cooke, 2002 1 Java technologies for presentation: JSP Today s lecture in the presentation tier Java Server Pages Tomcat examples Presentation How the web tier interacts with the

More information

GUJARAT TECHNOLOGICAL UNIVERSITY

GUJARAT TECHNOLOGICAL UNIVERSITY 1. Learning Objectives: To learn and work with the web components of Java EE. i.e. the Servlet specification. Student will be able to learn MVC architecture and develop dynamic web application using Java

More information

LTBP INDUSTRIAL TRAINING INSTITUTE

LTBP INDUSTRIAL TRAINING INSTITUTE Advance Java Servlet Basics of Servlet Servlet: What and Why? Basics of Web Servlet API Servlet Interface GenericServlet HttpServlet Servlet Li fe Cycle Working wi th Apache Tomcat Server Steps to create

More information

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22.

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22. Answers 1. What is the super interface to all the JDBC Drivers, specify their fully qualified name? a. Java.sql.Driver i. JDBC-ODBC Driver ii. Java-Native API Driver iii. All Java Net Driver iv. Java Native

More information

Introduction to Java Server Pages. Enabling Technologies - Plug-ins Scripted Pages

Introduction to Java Server Pages. Enabling Technologies - Plug-ins Scripted Pages Introduction to Java Server Pages Jeff Offutt & Ye Wu http://www.ise.gmu.edu/~offutt/ SWE 432 Design and Implementation of Software for the Web From servlets lecture. Enabling Technologies - Plug-ins Scripted

More information

JSP - SYNTAX. Any text, HTML tags, or JSP elements you write must be outside the scriptlet. Following is the simple and first example for JSP:

JSP - SYNTAX. Any text, HTML tags, or JSP elements you write must be outside the scriptlet. Following is the simple and first example for JSP: http://www.tutorialspoint.com/jsp/jsp_syntax.htm JSP - SYNTAX Copyright tutorialspoint.com This tutorial will give basic idea on simple syntax ie. elements involved with JSP development: The Scriptlet:

More information

JAVA MICROSERVICES. Java Language Environment. Java Set Up. Java Fundamentals. Packages. Operations

JAVA MICROSERVICES. Java Language Environment. Java Set Up. Java Fundamentals. Packages. Operations Java Language Environment JAVA MICROSERVICES Object Oriented Platform Independent Automatic Memory Management Compiled / Interpreted approach Robust Secure Dynamic Linking MultiThreaded Built-in Networking

More information

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started Application Development in JAVA Duration Lecture: Specialization x Hours Core Java (J2SE) & Advance Java (J2EE) Detailed Module Part I: Core Java (J2SE) Getting Started What is Java all about? Features

More information

FINALTERM EXAMINATION Spring 2009 CS506- Web Design and Development Solved by Tahseen Anwar

FINALTERM EXAMINATION Spring 2009 CS506- Web Design and Development Solved by Tahseen Anwar FINALTERM EXAMINATION Spring 2009 CS506- Web Design and Development Solved by Tahseen Anwar www.vuhelp.pk Solved MCQs with reference. inshallah you will found it 100% correct solution. Time: 120 min Marks:

More information

CSc31800: Internet Programming, CS-CCNY, Spring 2004 Jinzhong Niu May 9, JSPs 1

CSc31800: Internet Programming, CS-CCNY, Spring 2004 Jinzhong Niu May 9, JSPs 1 CSc31800: Internet Programming, CS-CCNY, Spring 2004 Jinzhong Niu May 9, 2004 JSPs 1 As we know, servlets, replacing the traditional CGI technology, can do computation and generate dynamic contents during

More information

Making applica+ons with Java. Text Technologies 2013 Chris Culy

Making applica+ons with Java. Text Technologies 2013 Chris Culy Making applica+ons with Java Desktop applica+on aka executable jar file Commandline: java jar myapplica+on.jar Or, if you have a GUI interface, doubleclick on the jar file Easiest solu+on: Let the IDE

More information

ADVANCED JAVA TRAINING IN BANGALORE

ADVANCED JAVA TRAINING IN BANGALORE ADVANCED JAVA TRAINING IN BANGALORE TIB ACADEMY #5/3 BEML LAYOUT, VARATHUR MAIN ROAD KUNDALAHALLI GATE, BANGALORE 560066 PH: +91-9513332301/2302 www.traininginbangalore.com 2EE Training Syllabus Java EE

More information

JSP. Basic Elements. For a Tutorial, see:

JSP. Basic Elements. For a Tutorial, see: JSP Basic Elements For a Tutorial, see: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/jspintro.html Simple.jsp JSP Lifecycle Server Web

More information

Module 3 Web Component

Module 3 Web Component Module 3 Component Model Objectives Describe the role of web components in a Java EE application Define the HTTP request-response model Compare Java servlets and JSP components Describe the basic session

More information

SESM Components and Techniques

SESM Components and Techniques CHAPTER 2 Use the Cisco SESM web application to dynamically render the look-and-feel of the user interface for each subscriber. This chapter describes the following topics: Using SESM Web Components, page

More information

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM Advanced Internet Technology Lab.

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM Advanced Internet Technology Lab. Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 5049 Advanced Internet Technology Lab Lab # 10 JAVABEANS IN JSP El-masry May, 2014 Objectives Understanding JavaBeans.

More information

Chapter 10 Servlets and Java Server Pages

Chapter 10 Servlets and Java Server Pages Chapter 10 Servlets and Java Server Pages 10.1 Overview of Servlets A servlet is a Java class designed to be run in the context of a special servlet container An instance of the servlet class is instantiated

More information

SECTION II: JAVA SERVLETS

SECTION II: JAVA SERVLETS Chapter 7 SECTION II: JAVA SERVLETS Working With Servlets Working with Servlets is an important step in the process of application development and delivery through the Internet. A Servlet as explained

More information

JavaServer Pages and the Expression Language

JavaServer Pages and the Expression Language JavaServer Pages and the Expression Language Bryan Basham Sun Microsystems, Inc. bryan.basham@sun.com Page 1 Topics Covered History of the Expression Language (EL) Overview of the EL EL Namespace EL Operators

More information

Table of Contents. Introduction... xxi

Table of Contents. Introduction... xxi Introduction... xxi Chapter 1: Getting Started with Web Applications in Java... 1 Introduction to Web Applications... 2 Benefits of Web Applications... 5 Technologies used in Web Applications... 5 Describing

More information

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p.

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p. Preface p. xiii Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p. 11 Creating the Deployment Descriptor p. 14 Deploying Servlets

More information

Sun Sun Certified Web Component Developer for J2EE 5 Version 4.0

Sun Sun Certified Web Component Developer for J2EE 5 Version 4.0 Sun Sun Certified Web Component Developer for J2EE 5 Version 4.0 QUESTION NO: 1 To take advantage of the capabilities of modern browsers that use web standards, such as XHTML and CSS, your web application

More information

Web Application Architecture (based J2EE 1.4 Tutorial)

Web Application Architecture (based J2EE 1.4 Tutorial) Web Application Architecture (based J2EE 1.4 Tutorial) Dr. Kanda Runapongsa (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University 1 Agenda Web application, components and container

More information

A JavaBean is a class file that stores Java code for a JSP

A JavaBean is a class file that stores Java code for a JSP CREATE A JAVABEAN A JavaBean is a class file that stores Java code for a JSP page. Although you can use a scriptlet to place Java code directly into a JSP page, it is considered better programming practice

More information

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes Java CORE JAVA Core Java Programing (Course Duration: 40 Hours) Introduction to Java What is Java? Why should we use Java? Java Platform Architecture Java Virtual Machine Java Runtime Environment A Simple

More information

11.1 Introduction to Servlets

11.1 Introduction to Servlets 11.1 Introduction to Servlets - A servlet is a Java object that responds to HTTP requests and is executed on a Web server - Servlets are managed by the servlet container, or servlet engine - Servlets are

More information

Jakarta Struts: An MVC Framework

Jakarta Struts: An MVC Framework Jakarta Struts: An MVC Framework Overview, Installation, and Setup. Struts 1.2 Version. Core Servlets & JSP book: More Servlets & JSP book: www.moreservlets.com Servlet/JSP/Struts/JSF Training: courses.coreservlets.com

More information

Peers Techno log ies Pv t. L td. Core Java & Core Java &Adv Adv Java Java

Peers Techno log ies Pv t. L td. Core Java & Core Java &Adv Adv Java Java Page 1 Peers Techno log ies Pv t. L td. Course Brochure Core Java & Core Java &Adv Adv Java Java Overview Core Java training course is intended for students without an extensive programming background.

More information

01KPS BF Progettazione di applicazioni web

01KPS BF Progettazione di applicazioni web 01KPS BF Progettazione di applicazioni web Introduction to Java Server Pages Fulvio Corno, Alessio Bosca Dipartimento di Automatica e Informatica Politecnico di Torino PAW - JSP intro 1 Introduction to

More information

Developing Applications with Java EE 6 on WebLogic Server 12c

Developing Applications with Java EE 6 on WebLogic Server 12c Developing Applications with Java EE 6 on WebLogic Server 12c Duration: 5 Days What you will learn The Developing Applications with Java EE 6 on WebLogic Server 12c course teaches you the skills you need

More information

Servlets by Example. Joe Howse 7 June 2011

Servlets by Example. Joe Howse 7 June 2011 Servlets by Example Joe Howse 7 June 2011 What is a servlet? A servlet is a Java application that receives HTTP requests as input and generates HTTP responses as output. As the name implies, it runs on

More information

JSF: Introduction, Installation, and Setup

JSF: Introduction, Installation, and Setup 2007 Marty Hall JSF: Introduction, Installation, and Setup Originals of Slides and Source Code for Examples: http://www.coreservlets.com/jsf-tutorial/ Customized J2EE Training: http://courses.coreservlets.com/

More information

CE212 Web Application Programming Part 3

CE212 Web Application Programming Part 3 CE212 Web Application Programming Part 3 30/01/2018 CE212 Part 4 1 Servlets 1 A servlet is a Java program running in a server engine containing methods that respond to requests from browsers by generating

More information

Java- EE Web Application Development with Enterprise JavaBeans and Web Services

Java- EE Web Application Development with Enterprise JavaBeans and Web Services Java- EE Web Application Development with Enterprise JavaBeans and Web Services Duration:60 HOURS Price: INR 8000 SAVE NOW! INR 7000 until December 1, 2011 Students Will Learn How to write Session, Message-Driven

More information

LearningPatterns, Inc. Courseware Student Guide

LearningPatterns, Inc. Courseware Student Guide Fast Track to Servlets and JSP Developer's Workshop LearningPatterns, Inc. Courseware Student Guide This material is copyrighted by LearningPatterns Inc. This content shall not be reproduced, edited, or

More information

jmaki Overview Sang Shin Java Technology Architect Sun Microsystems, Inc.

jmaki Overview Sang Shin Java Technology Architect Sun Microsystems, Inc. jmaki Overview Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com www.javapassion.com Agenda What is and Why jmaki? jmaki widgets Using jmaki widget - List widget What makes up

More information

Contents. 1. JSF overview. 2. JSF example

Contents. 1. JSF overview. 2. JSF example Introduction to JSF Contents 1. JSF overview 2. JSF example 2 1. JSF Overview What is JavaServer Faces technology? Architecture of a JSF application Benefits of JSF technology JSF versions and tools Additional

More information

Model View Controller (MVC)

Model View Controller (MVC) Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 5049 Advanced Internet Technology Lab Lab # 11 Model View Controller (MVC) El-masry May, 2014 Objectives To be

More information

directive attribute1= value1 attribute2= value2... attributen= valuen %>

directive attribute1= value1 attribute2= value2... attributen= valuen %> JSP Standard Syntax Besides HTML tag elements, JSP provides four basic categories of constructors (markup tags): directives, scripting elements, standard actions, and comments. You can author a JSP page

More information

JSP: Servlets Turned Inside Out

JSP: Servlets Turned Inside Out Chapter 19 JSP: Servlets Turned Inside Out In our last chapter, the BudgetPro servlet example spent a lot of code generating the HTML output for the servlet to send back to the browser. If you want to

More information

sessionx Desarrollo de Aplicaciones en Red EL (2) EL (1) Implicit objects in EL Literals José Rafael Rojano Cáceres

sessionx Desarrollo de Aplicaciones en Red EL (2) EL (1) Implicit objects in EL Literals José Rafael Rojano Cáceres sessionx Desarrollo de Aplicaciones en Red José Rafael Rojano Cáceres http://www.uv.mx/rrojano EL Expression Language Write the code in something else, just let EL call it. EL () EL stand for Expression

More information

JavaServer Pages. Juan Cruz Kevin Hessels Ian Moon

JavaServer Pages. Juan Cruz Kevin Hessels Ian Moon Page 1 of 14 JavaServer Pages Table of Contents 1. Introduction What is JSP? Alternative Solutions Why Use JSP? 2. JSP Process Request Compilation Example 3. Object Instantiation and Scope Scope Synchronization

More information

Servlet Fudamentals. Celsina Bignoli

Servlet Fudamentals. Celsina Bignoli Servlet Fudamentals Celsina Bignoli bignolic@smccd.net What can you build with Servlets? Search Engines E-Commerce Applications Shopping Carts Product Catalogs Intranet Applications Groupware Applications:

More information

First Simple Interactive JSP example

First Simple Interactive JSP example Let s look at our first simple interactive JSP example named hellojsp.jsp. In his Hello User example, the HTML page takes a user name from a HTML form and sends a request to a JSP page, and JSP page generates

More information

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http?

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http? What are Servlets? Servlets1 Fatemeh Abbasinejad abbasine@cs.ucdavis.edu A program that runs on a web server acting as middle layer between requests coming from a web browser and databases or applications

More information

Session 9. Deployment Descriptor Http. Reading and Reference. en.wikipedia.org/wiki/http. en.wikipedia.org/wiki/list_of_http_headers

Session 9. Deployment Descriptor Http. Reading and Reference. en.wikipedia.org/wiki/http. en.wikipedia.org/wiki/list_of_http_headers Session 9 Deployment Descriptor Http 1 Reading Reading and Reference en.wikipedia.org/wiki/http Reference http headers en.wikipedia.org/wiki/list_of_http_headers http status codes en.wikipedia.org/wiki/http_status_codes

More information

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming PSD1B Advance Java Programming Unit : I-V PSD1B- Advance Java Programming 1 UNIT I - SYLLABUS Servlets Client Vs Server Types of Servlets Life Cycle of Servlets Architecture Session Tracking Cookies JDBC

More information

JSP MOCK TEST JSP MOCK TEST IV

JSP MOCK TEST JSP MOCK TEST IV http://www.tutorialspoint.com JSP MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to JSP Framework. You can download these sample mock tests at your local

More information

Life Without NetBeans

Life Without NetBeans Life Without NetBeans Part C Web Applications Background What is a WAR? A Java web application consists a collection of Java servlets and regular classes, JSP files, HTML files, JavaScript files, images,

More information

Trabalhando com JavaServer Pages (JSP)

Trabalhando com JavaServer Pages (JSP) Trabalhando com JavaServer Pages (JSP) Sumário 7.2.1 Introdução 7.2.2 JavaServer Pages Overview 7.2.3 First JavaServer Page Example 7.2. Implicit Objects 7.2.5 Scripting 7.2.5.1 Scripting Components 7.2.5.2

More information

<Insert Picture Here> Exploring Java EE 6 The Programming Model Explained

<Insert Picture Here> Exploring Java EE 6 The Programming Model Explained Exploring Java EE 6 The Programming Model Explained Lee Chuk Munn chuk-munn.lee@oracle.com The following is intended to outline our general product direction. It is intended for information

More information

Web Applications. and. Struts 2

Web Applications. and. Struts 2 Web Applications and Struts 2 Problem area Why use web frameworks? Separation of application logic and markup Easier to change and maintain Easier to re-use Less error prone Access to functionality to

More information

20/08/56. Java Technology, Faculty of Computer Engineering, KMITL 1

20/08/56. Java Technology, Faculty of Computer Engineering, KMITL 1 Engineering, KMITL 1 Agenda What is JSP? Life-cycle of JSP page Steps for developing JSP-based Web application Dynamic contents generation techniques in JSP Three main JSP constructs Directives Error handling

More information

SNS COLLEGE OF ENGINEERING, Coimbatore

SNS COLLEGE OF ENGINEERING, Coimbatore SNS COLLEGE OF ENGINEERING, Coimbatore 641 107 Accredited by NAAC UGC with A Grade Approved by AICTE and Affiliated to Anna University, Chennai IT6503 WEB PROGRAMMING UNIT 04 APPLETS Java applets- Life

More information

SSC - Web applications and development Introduction and Java Servlet (I)

SSC - Web applications and development Introduction and Java Servlet (I) SSC - Web applications and development Introduction and Java Servlet (I) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics What will we learn

More information

Université du Québec à Montréal

Université du Québec à Montréal Laboratoire de Recherches sur les Technologies du Commerce Électronique arxiv:1803.05253v1 [cs.se] 14 Mar 2018 Université du Québec à Montréal How to Implement Dependencies in Server Pages of JEE Web Applications

More information

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1 Java Enterprise Edition Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1 Java Beans Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 2 Java Bean POJO class : private Attributes public

More information