Caching Web Sample Application

> Caching Web Sample Application

> This document describes how to use the caching web sample application in conjunction with Sun ONE Web Server.

> This sample application document contains the following sections:

> - Overview

> - Compiling and Assembling the Application

> - Deploying the Sample Application

> - Running the Sample Application

> Overview

> The caching web sample application demonstrates how to use servlet/JSP caching on the Sun ONE Web Server. Sun One Web Server provides value-added services that enable results caching at both the JSP and servlet level. Using results caching enables you to increase 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 caching web sample application:
> 1. Go to <install_root>/plugins/java/samples/webapps/caching/src and execute the ant command.
>    The default target 'default' will be executed to build the WAR file.
> 2. Deploy the application.
>    After you have re-created the sample application from scratch, you can proceed to Deploying the Sample Application. Step 3 is optional.
> 3. Clean the web application project area (optional).
>    Execute the command ant clean to clean the web application.

> Deploying the Sample Application

> To deploy the caching web sample application:

> > 1. Go to the src directory of the sample. For example:

> <install_root>/plugins/java/samples/webapps/caching/src
> 1. Run ant using the deploy task. For example:
>    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

> As an optional step, you can use the Sun ONE Web Server Deploy Tool to verify that the application has been registered.

> To verify the registration of the application, do the following:

> 1. Go to the src directory of the sample. For example:
>    <install_root>/plugins/java/samples/webapps/caching/src

> 2. Run the ant tool using the list_apps task. For example:
>    ant list_apps
>    You will see the webapps-caching module displayed as one of the listed components.

> Undeploying the Application

> To undeploy the application after successful deployment:

> 1. Go to <install_root>/plugins/java/samples/webapps/caching/src

> 2. Execute the following:

>    ant undeploy

> Running the Sample Application

> You can run the application through the following URL:

> http://<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," irrespective 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.

> Copyright © 2003 Sun Microsystems, Inc. All rights reserved.