JSP Thanks to http courses coreservlets com CourseMaterialscsajsp

  • Slides: 50
Download presentation
JSP Thanks to http: //courses. coreservlets. com/ Course-Materials/csajsp 2. html

JSP Thanks to http: //courses. coreservlets. com/ Course-Materials/csajsp 2. html

The 10 most popular sites (Summer. 10)

The 10 most popular sites (Summer. 10)

Keywords in job posting

Keywords in job posting

Java Web Technology in… AIRLINES

Java Web Technology in… AIRLINES

Java Web Technology in… TRAVEL

Java Web Technology in… TRAVEL

Java Web Technology in… FINANCIAL SERVICES

Java Web Technology in… FINANCIAL SERVICES

Java Web Technology in… RETAIL

Java Web Technology in… RETAIL

Java Web Technology in… SEARCH PORTALS

Java Web Technology in… SEARCH PORTALS

Servlets pros and cons

Servlets pros and cons

JSP - The idea

JSP - The idea

JSP advantages

JSP advantages

JSP Lifecycle Server Web Pagina JSP Browser Servlet generato Servlet compilato

JSP Lifecycle Server Web Pagina JSP Browser Servlet generato Servlet compilato

JSP - MISCONCEPTIONS

JSP - MISCONCEPTIONS

What happens when?

What happens when?

Event table

Event table

JSP nuts and bolts • • Syntactic elements: <%@ directives %> <%! declarations %>

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

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?

Two sintaxes - why?

xml syntax for HTML 4 files

xml syntax for HTML 4 files

XML syntax for XHTML files

XML syntax for XHTML files

JSP expressions

JSP expressions

How is it translated?

How is it translated?

Example

Example

Predefined variables

Predefined variables

Example

Example

Scope of the predefined variables

Scope of the predefined variables

Scriptlets

Scriptlets

How gets is translated?

How gets is translated?

Example

Example

A scriptlet does NOT need to be a complete Java expression

A scriptlet does NOT need to be a complete Java expression

JSP declarations

JSP declarations

How gets it translated? 1

How gets it translated? 1

How gets it translated - 2

How gets it translated - 2

Example

Example

jsp. Init - jsp. Destroy

jsp. Init - jsp. Destroy

Let's recap…

Let's recap…

import page directive

import page directive

content. Type -page. Encoding

content. Type -page. Encoding

Session

Session

Error page

Error page

is. Error. Page

is. Error. Page

is. Thread. Safe Don't you be lazy….

is. Thread. Safe Don't you be lazy….

What's wrong here?

What's wrong here?

Should you use "is. Thread. Safe" ?

Should you use "is. Thread. Safe" ?

@include

@include

jsp: include

jsp: include

jsp: include vs @ include

jsp: include vs @ include

Augmenting request params

Augmenting request params

Static pages To let Tomcat serve static pages, we must define a “Web Application”.

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

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