Including JavaScript source code
The next two script tags incorporate the JavaScript source files tree.js and script.js into the page so
that functions contained in these JS files can be called from the page.
<script language="JavaScript" src="js/tree.js"></script>
<script language="JavaScript" src="js/scripts.js"></script>
The chunk of JavaScript code between the <script> and </script> tags refreshes the window to
apply the styles of the CSS file specified by the Bean to the page, then adds functionality to
determine the number of results to return when searches are performed.
Including the JSPs that comprise the main template
The body of the page includes several other JSP pages that constitute the sections making up the
adminTemplate page. The first two pages included are the adminHeader and adminNavItems
JSPs. Another standard JSP action, the include tag, is used to incorporate the adminHeader.jsp
and adminNavItems.jsp files. The HTML table, tr, and td tags help to structure the layout of the
content.
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"
onUnload="unload();" onLoad="<%= onLoad %>" >
<%---------------------------------------------------------------------
--------------
The first jsp page to include is adminHeader, which contains the logo
image and
preferences buttons.
After that, the adminNavItems page includes all of the main tabs
----------------------------------------------------------------------
------------%>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
background="">
<tr>
<td background="images/bckPrimHeader.jpg">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><jsp:include page="adminHeader.jsp" flush="true"/></td>
</tr>
<tr>
<td valign="bottom" background=""><br><jsp:include
page="adminNavItems.jsp"
flush="true"/></td>
</tr>
</table>
</td>
</tr>
</table>
In the following piece of code, the JSP uses a JavaBean to query the request to determine if the
current navigation mode is the student home page. If it is, the studentHomeNavigation.jsp is
included in the page also. This piece of code demonstrates how Struts-logic.tld tags work. The
logic:match tag checks if the value of the navKey variable, which checks the request for the
Chapter 5: Customizing JavaServer Pages 25