29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A point of note concerns the session attribute. As explained, if the session<br />

attribute is set to true, or not specified at all, then the session implicit object<br />

variable will reference the HttpSession object for the requesting client. If there is<br />

no HttpSession object available, then one will be created explicitly. This can<br />

create a performance overhead if your JSP page is not intended to interact with<br />

session objects. If this is the case, then you should ensure that the directive tag is included within your JSP.<br />

The list in Example 8-3 shows a snippet of JSP source code containing example<br />

page directives.<br />

Example 8-3 Page directive example<br />

<br />

<br />

Date and time<br />

<br />

<br />

<br />

<br />

The current date and time is: <br />

<br />

<br />

The include directive<br />

The include directive allows content held in other files on the server file system to<br />

be included within the JSP page source at translation time. That is, the contents<br />

of the included file will be included in the JSP source at the point where the tag is<br />

defined and therefore processed by the JSP page compilation procedure. The<br />

included file may contain both static content and other JSP tags. The include<br />

page directive takes one attribute: file.<br />

The file attribute defines a relative URL, or URI, to the file to be included within<br />

the JSP page. This URI may be either page or context relative.<br />

The included file may contain any valid JSP tags. These tags will be translated to<br />

Java source and included in the JSP page compilation class. The rules regarding<br />

page directives stated in “The page directive” on page 248 still apply to page<br />

directive tags within the included file. A page directive tag contained within the<br />

included file will apply to the whole JSP at translation time. Any page directives<br />

within the included file that conflict with tags contained in the “including” JSP<br />

source will cause compilation time errors. For instance, if a JSP file contains a<br />

page directive specifying session=“false”, and then includes another file<br />

containing a JSP scripting element referencing the session attribute, a error will<br />

occur.<br />

250 <strong>IBM</strong> <strong>WebSphere</strong> <strong>Application</strong> <strong>Server</strong> - Express V5.0.2 Developer Handbook

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

Saved successfully!

Ooh no, something went wrong!