Java Reference
In-Depth Information
a browser, the compiled code would then be executed. All subsequent browser
requests for this JSP would cause the compiled code to be executed on the server.
This would continue to be the case until either the server was shut down (a rare
event for most Web servers) or the JSP source code was changed. (The Web server
detects a change by comparing dates of source and compiled fi les.)
A consequence of the above is that, if the fi rst time that a JSP is referenced by the
Web server occurs when a request is received from a browser, there is a noticeable
delay for the user of the browser as the Web server goes through the conversion and
translation phases before executing the compiled code. In order to avoid this fi rst-
time delay, pre-compiled JSPs may be used. One way of creating pre-compiled
JSPs is for the Web page developer to use a development environment to go through
all the JSPs on the site (causing the conversion-compilation-execution cycle to be
performed) and then save the resultant .class fi les in the appropriate directory of the
production version of the site. However, a more convenient way of producing the
precompiled pages is provided by the JSP specifi cation in the form of a special
request parameter called jsp_precompile . Use of this parameter avoids the need to
execute the associated JSP and may be used by a JSP container to produce the
required .class fi le(s). Like any request parameter included within a URL, jsp_pre-
compile is preceded by a question mark. The following example shows the format
required to precompile a JSP called MyPage.jsp :
MyPage.jsp?jsp_precompile
The parameter jsp_precompile is a Boolean parameter, so the above line could
alternatively end in jsp_precompile=true to make this explicit. However,
this is not necessary, since the default value for this parameter is true .
When a browser calls up a Web page, the Web server executes the compiled JSP
elements to produce HTML elements, merges these with the static HTML elements
of the page and serves up the completed page to the browser. One important differ-
ence between testing servlets and testing JSPs is that it is not necessary to stop and
restart the server when changes are made to a JSP.
9.3
JSP Tags
In addition to standard HTML tags and ordinary text, a number of JSP-specifi c tags
may be used on a JavaServer Page. The differing categories of JSP tag are listed
below. This list is followed by a description of the purpose of each category, its
required syntax and associated brief examples.
￿
Directives.
￿
Declarations.
￿
Expressions.
￿
Scriptlets.
￿
Comments.
￿
Actions.
Search WWH ::




Custom Search