29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

In fact, in <strong>WebSphere</strong>’s JSP implementation, the foo.jsp file is translated into two<br />

files: A .java file containing the Java code for the servlet, and a .dat file containing<br />

the static elements of the JSP. The .dat file actually contains a serialized array of<br />

byte arrays, with each byte array containing the static page elements before the<br />

next JSP tag. The .java file is then compiled to create a .class file, which<br />

represents the compiled servlet.<br />

The .class and .dat files are stored on the file system. The .java file may or may<br />

not be retained after the translation stage. This translation phase is performed<br />

once per JSP. If a compiled class file already exists on the file system, then the<br />

request for the JSP proceeds directly to phase 2.<br />

Phase 2: Request processing<br />

Phase 2 represents the actual invocation of the compiled servlet—the JSP page<br />

implementation class—to provide a response to the initial request.<br />

For Request 1, this phase is entered immediately after phase 1. If the servlet is<br />

not already loaded, it is brought into memory and the request serviced.<br />

For Request 2, the Web container knows of the existence of an already compiled<br />

servlet class loaded in memory, and directly services the request.<br />

By default, the JSP implementation in <strong>WebSphere</strong> also checks the source .jsp<br />

file for changes. If it has been modified it will enter the translation phase. Each<br />

subsequent request is handled by the servlet until the servlet is unloaded from<br />

memory, for instance, when the application server is stopped. This load/service<br />

request/unload life cycle is exactly the same as for servlets.<br />

8.1.2 Syntax for coding Java<strong>Server</strong> Pages<br />

Java<strong>Server</strong> Pages can be coded using two alternative methods: JSP syntax or<br />

XML syntax. The two cannot be mixed within a page. Beginning with JSP 1.2,<br />

JSP pages written in XML (referred to as JSP documents) can be delivered to the<br />

Web container for processing.<br />

The traditional JSP syntax looks like that shown in Example 8-1.<br />

Example 8-1 JSP syntax<br />

<br />

<br />

<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!