Caching Web Sample Application

 

Caching Web Sample Application
 

This document describes how to use the caching web sample application with the Sun Java System Web Server.

This document contains the following sections:


Overview

The caching web sample application demonstrates how to use servlet/JavaServer Pages (JSP) caching on the Sun Java System Web Server. The Sun Java System Web Server provides value-added services that enable results caching at both the JSP and servlet level. Results caching increases server performance by allowing subsequent calls to JSPs and servlets to be returned using cached results, instead of reinvoking Java code to generate the resulting content from scratch.

The servlet caching sample demonstrates how servlet caching can be controlled using deployment descriptors (sun-web.xml). The cache on/off timeouts can be adjusted at deployment time without any coding changes.


Compiling and Assembling the Application

To compile and assemble the sample application, complete the following steps:
  1. Compile and assemble the WAR file by changing to the source directory at install_root/samples/java/webapps/caching/src and running the ant command.
     
    The default target default is executed to build the WAR file.
     
    Note - Make sure that the necessary parameters for running the samples are specified in install_root/samples/java/webapps/common.properties.

  2. Deploy the application.

    After you have re-created the sample application from scratch, you can proceed to Deploying the Sample Application.
     
  3. (Optional.) Clean the web application project area.

    # ant clean

    This removes the assemble and build directories for the sample application. The WAR file is now ready for deployment.

Deploying the Sample Application

To deploy the sample application, complete the following steps:
  1. Change to the source directory at install_root/samples/java/webapps/caching/src.

  2. Run the ant tool using the deploy task.

    # ant deploy
If you want to verify the registration of the application, proceed to Verifying Deployment. Otherwise, proceed to Running the Sample Application.
 

Verifying Deployment

To verify the registration and deployment of the application, complete the following steps:  

  1. Change to the source directory at install_root/samples/java/webapps/caching/src.

  2. Run the ant tool using the list_apps task.

    # ant list_apps

    The webapps-caching module is listed as one of the components.


Running the Sample Application

You can run the application through the following URL:

http://Sun_Java_System_Web_Server_hostname:port/webapps-caching

Servlet Caching. Based on the value in the sun-web.xml file, the results are cached if the Input String is either one or two, regardless of whether the Delivery Mechanism is Servlet Only or Via JSP. If you want to turn the cache off or change the cache timeout value, you can do so by modifying the attributes of the cache element in the sun-web.xml file.

Undeploying the Sample Application

After successfully deploying and running the application, you might decide to undeploy it and remove the files. To undeploy the application, complete the following steps:  

  1. Change to the source directory at install_root/samples/java/webapps/caching/src.

  2. Run the ant tool using the undeploy task.

    # ant undeploy


Copyright © 2007 Sun Microsystems, Inc. All rights reserved.