Sei sulla pagina 1di 2

JSP - ARCHITECTURE

http://www.tuto rialspo int.co m/jsp/jsp_archite cture .htm

Co pyrig ht tuto rials po int.co m

T he web server needs a JSP eng ine ie. container to process JSP pag es. T he JSP container is responsible for
intercepting requests for JSP pag es. T his tutorial makes use of Apache which has built-in JSP container to
support JSP pag es development.
A JSP container works with the Web server to provide the runtime environment and other services a JSP needs.
It knows how to understand the special elements that are part of JSPs.
Following diag ram shows the position of JSP container and JSP files in a Web Application.

JSP Processing :
T he following steps explain how the web server creates the web pag e using JSP:
As with a normal pag e, your browser sends an HT T P request to the web server.
T he web server recog nizes that the HT T P request is for a JSP pag e and forwards it to a JSP eng ine.
T his is done by using the URL or JSP pag e which ends with .jsp instead of .html.
T he JSP eng ine loads the JSP pag e from disk and converts it into a servlet content. T his conversion is
very simple in which all template text is converted to println( ) statements and all JSP elements are
converted to Java code that implements the corresponding dynamic behavior of the pag e.
T he JSP eng ine compiles the servlet into an executable class and forwards the orig inal request to a
servlet eng ine.
A part of the web server called the servlet eng ine loads the Servlet class and executes it. During
execution, the servlet produces an output in HT ML format, which the servlet eng ine passes to the web
server inside an HT T P response.
T he web server forwards the HT T P response to your browser in terms of static HT ML content.
Finally web browser handles the dynamically g enerated HT ML pag e inside the HT T P response exactly
as if it were a static pag e.
All the above mentioned steps can be shown below in the following diag ram:

T ypically, the JSP eng ine checks to see whether a servlet for a JSP file already exists and whether the
modification date on the JSP is older than the servlet. If the JSP is older than its g enerated servlet, the JSP
container assumes that the JSP hasn't chang ed and that the g enerated servlet still matches the JSP's contents.
T his makes the process more efficient than with other scripting lang uag es (such as PHP) and therefore faster.
So in a way, a JSP pag e is really just another way to write a servlet without having to be a Java prog ramming wiz.
Except for the translation phase, a JSP pag e is handled exactly like a reg ular servlet

Potrebbero piacerti anche