JSP Thanks to http courses coreservlets com CourseMaterialscsajsp


















































- Slides: 50
JSP Thanks to http: //courses. coreservlets. com/ Course-Materials/csajsp 2. html
The 10 most popular sites (Summer. 10)
Keywords in job posting
Java Web Technology in… AIRLINES
Java Web Technology in… TRAVEL
Java Web Technology in… FINANCIAL SERVICES
Java Web Technology in… RETAIL
Java Web Technology in… SEARCH PORTALS
Servlets pros and cons
JSP - The idea
JSP advantages
JSP Lifecycle Server Web Pagina JSP Browser Servlet generato Servlet compilato
JSP - MISCONCEPTIONS
What happens when?
Event table
JSP nuts and bolts • • Syntactic elements: <%@ directives %> <%! declarations %> <% scriptlets %> <%= expressions %> <jsp: actions/> <%-- Comment --%> Implicit Objects: • request • response • page. Context • session • application • out • config • page
JSP nuts and bolts • Syntactic elements: • <%@ directives %> Interaction with the CONTAINER • <%! declarations %> In the initialization of the JSP • <% scriptlets %> In the service method • <%= expressions %> In the service method • <jsp: actions/> •
Two sintaxes - why?
xml syntax for HTML 4 files
XML syntax for XHTML files
JSP expressions
How is it translated?
Example
Predefined variables
Example
Scope of the predefined variables
Scriptlets
How gets is translated?
Example
A scriptlet does NOT need to be a complete Java expression
JSP declarations
How gets it translated? 1
How gets it translated - 2
Example
jsp. Init - jsp. Destroy
Let's recap…
import page directive
content. Type -page. Encoding
Session
Error page
is. Error. Page
is. Thread. Safe Don't you be lazy….
What's wrong here?
Should you use "is. Thread. Safe" ?
@include
jsp: include
jsp: include vs @ include
Augmenting request params
Static pages To let Tomcat serve static pages, we must define a “Web Application”. That is, in the Tomcat Document Root (by default $CATALINA_HOME/webapps/) we must create a folder named after our Web Application (e. g. my. App). webapps my. App In that “my. App” folder, we MUST create a WEB-INF folder (that can be empy). WEB-INF In the my. App folder we can then depost the static html files. On our Tomcat server, the URL for the hello. html file becomes: web. xml http: //machine/port/my. App/hello. html To actually see the webapp, we might have to restart Tomcat hello. html
JSP pages To let Tomcat serve JSP pages, we follow the same procedure that we described for static pages. webapps In the my. App folder we can depost the JSP files. On our Tomcat server, the URL for the hello. jsp file becomes: http: //machine/port/my. App/hello. jsp my. App The WEB-INF directory is still empty. To actually see the webapp, you might have to restart Tomcat (depending on the version you have) The same web. xml file as in the static case must be provided. WEB-INF web. xml hello. jsp