Contents | Prev | Next



Examples

The examples described in this section demonstrate solutions to two recurring problems in developing JSP applications: minimizing the amount of Java programming in JSP pages and ensuring a common look and feel across applications. In doing so, they illustrate many of the styles of tags discussed in the first section.

The complete binary and source code for the examples is in two Web application archives iteration.war and template.war contained in the archive examples.zip. You can unpack the Web application archives with the command jar xvf webapp.war.

When an archive is unpacked, its contents are deposited into the directories listed in the following table. This directory layout is required by the Java Servlet specification and is one that you usually will use while developing an application.

Table 5 Web Application Directory Structure

Directory

Contents

webapp

JSP and HTML files

webapp/WEB-INF

web.xml (Web application deployment descriptor) and taglib.tld (tag library descriptor)

webapp/WEB-INF/classes

classes accessed by JSP files and servlet implementations

webapp/WEB-INF/lib

JAR files containing the binary and source of tag library handler and tag extra info classes

You can run the examples on Tomcat, the freely available implementation of the Java Servlet and JavaServer Pages technologies, by performing the following steps:

  1. Install Tomcat.
  2. Download the Web application archives into the directory TOMCAT_HOME/webapps. When an archived Web application is accessed, Tomcat 3.2 automatically unpacks it into the directory TOMCAT_HOME/docBase (where docBase is the application directory specified in server.xml) and adds the context for each archive to the server startup file. If you are using an earlier version of Tomcat you will need to add the following lines to the file TOMCAT_HOME/conf/server.xml:
    <Context path="/iteration" docBase="webapps/iteration" debug="0" reloadable="true" />
    <Context path="/template" docBase="webapps/template" debug="0" reloadable="true" />
  3. Start Tomcat.
  4. Invoke the examples by following the links:
http://localhost:8080/iteration
http://localhost:8080/template/example/home


Contents | Prev | Next
Copyright © 2000 Sun Microsystems, Inc. All rights reserved.