6.3. The Second-Level Pages

The top-level page introduces the site and gives links to each of the three second-level pages that describe specific varieties of boats: yachts (Listing 6.7, Figure 6-2), oil tankers (Listing 6.8, Figure 6-3), and aircraft carriers (Listing 6.9, Figure 6-4). Note that simple relative URLs are used for the style sheet and for the servlet with which the form communicates when the user asks for details. Note also that the custom tag maintains the count from the top-level page. That’s because the servlet context is shared by all pages in the Web app.

Figure 6-2. Result of yachts.jsp.


Figure 6-3. Result of tankers.jsp.


Figure 6-4. Result of carriers.jsp.


Once the user chooses a particular model and asks for more information on it, the item display servlet is invoked. Since the web.xml file (Listing 6.2) registers this servlet with the URL suffix DisplayItem, a simple relative URL can be used for the ACTION attribute of the FORM element. As described in Section 4.5 (Handling Relative URLs in Web Applications), this capability is important because it permits the servlet to use simple relative URLs either directly or by means of JSP pages to which it forwards the request. That means that the Web application name can be changed without necessitating changes to these JSP pages. See the following subsection for details on the item display servlet.

Listing 6.7. boats/yachts.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<HTML> 
<HEAD> 
<TITLE>Yachts</TITLE> 
<LINK REL=STYLESHEET 
      HREF="app-styles.css" 
      TYPE="text/css"> 
</HEAD> 

<BODY> 
<TABLE BORDER=5 ALIGN="CENTER"> 
  <TR><TH CLASS="TITLE">Yachts</TABLE> 
<P> 
Luxurious models for the <S>wasteful</S> 
wealthy buyer. 

<H2>Available Models</H2> 
Choose a model to see a picture along with price and 
availability information. 
<FORM ACTION="DisplayItem"> 
<INPUT TYPE="RADIO" NAME="itemNum" VALUE="BM1"> 
Base Model -- Includes 4-car garage<BR> 
<INPUT TYPE="RADIO" NAME="itemNum" VALUE="MR1"> 
Mid Range -- Has 15 bedrooms and a helipad<BR> 
<INPUT TYPE="RADIO" NAME="itemNum" VALUE="HE1"> 
High End -- Free tropical island nation included 
<P> 
<CENTER> 
<INPUT TYPE="SUBMIT" VALUE="Get Details"> 
</CENTER> 
</FORM> 

<%-- Note the lack of "boats" at the front of URI below --%> 
<%@ taglib uri="/WEB-INF/tlds/count-taglib.tld" prefix="boats" %> 
<boats:count /> 
</BODY> 
</HTML> 

Listing 6.8. boats/tankers.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<HTML> 
<HEAD> 
<TITLE>Oil Tankers</TITLE> 
<LINK REL=STYLESHEET 
      HREF="app-styles.css" 
      TYPE="text/css"> 
</HEAD> 

<BODY> 
<TABLE BORDER=5 ALIGN="CENTER"> 
  <TR><TH CLASS="TITLE">Oil Tankers</TABLE> 
<P> 
Stable and roomy models for the <S>uninformed</S> 
innovative buyer. 

<H2>Available Models</H2> 
Choose a model to see a picture along with price and 
availability information. 
<FORM ACTION="DisplayItem"> 
<INPUT TYPE="RADIO" NAME="itemNum" VALUE="Valdez"> 
Valdez -- Slightly damaged model available at discount<BR> 
<INPUT TYPE="RADIO" NAME="itemNum" VALUE="BigBertha"> 
Big Bertha -- Includes 10 million gallon swimming pool<BR> 
<INPUT TYPE="RADIO" NAME="itemNum" VALUE="EcoDisaster"> 
ED I -- For those who don't mind political incorrectness 
<P> 
<CENTER> 
<INPUT TYPE="SUBMIT" VALUE="Get Details"> 
</CENTER> 
</FORM> 

<%-- Note the lack of "boats" at the front of URI below --%> 
<%@ taglib uri="/WEB-INF/tlds/count-taglib.tld" prefix="boats" %> 
<boats:count /> 
</BODY> 
</HTML> 

Listing 6.9. boats/carriers.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<HTML> 
<HEAD> 
<TITLE>Aircraft Carriers</TITLE> 
<LINK REL=STYLESHEET 
      HREF="app-styles.css" 
      TYPE="text/css"> 
</HEAD> 

<BODY> 
<TABLE BORDER=5 ALIGN="CENTER"> 
  <TR><TH CLASS="TITLE">Aircraft Carriers</TABLE> 
<P> 
High-security models for the <S>paranoid</S> careful buyer. 

<H2>Available Models</H2> 
Choose a model to see a picture along with price and 
availability information. 
<FORM ACTION="DisplayItem"> 
<INPUT TYPE="RADIO" NAME="itemNum" VALUE="SafeT-1A"> 
SafeT-1A -- Our Most Popular Model<BR> 
<INPUT TYPE="RADIO" NAME="itemNum" VALUE="SafeT-1B"> 
SafeT-1B -- 1000-man crew included<BR> 
<INPUT TYPE="RADIO" NAME="itemNum" VALUE="Lubber-1"> 
Land Lubber I -- Land-based replica; no water to worry about! 
<P> 
<CENTER> 
<INPUT TYPE="SUBMIT" VALUE="Get Details"> 
</CENTER> 
</FORM> 

<%-- Note the lack of "boats" at the front of URI below --%> 
<%@ taglib uri="/WEB-INF/tlds/count-taglib.tld" prefix="boats" %> 
<boats:count /> 
</BODY> 
</HTML> 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.4.179