| Caching Web Sample Application |
Caching Web Sample Application
This document describes how to utilize the Caching Web sample application in conjunction with the Application Server.This sample application document contains the following sections:
- Overview
- Compiling and Assembling the Application
- Deploying the Sample Application
Overview
The Caching Web sample application demonstrates how to utilize servlet/JSP caching on the application server. The Application 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, time-outs can be adjusted at deployment time without any coding changes content from scratch.
The JSP caching sample shows how JSP caching can be achieved by utilizing JSP tags. The cache on/off, cache time-out can be controlled by the attribute value of the JSP tag.
To better understand sample application source code, you may refer to the related javadocs which can be accessed at <install_root>/samples/webapps/caching/javadocs/index.html after it is generated.
Compiling and Assembling the Application
This section contains instructions to compile and assemble the Caching Web sample application.
- Go to <install_root>/samples/webapps/caching/src/
- Execute the command asant
Note You must add <install_root>/bin to your path.
- The default target core will be executed to build the WAR file.
- Deploy the application.
- After you have re-created the sample application from scratch, you may proceed to Deploying the Sample Application. Step 3 is optional.
- Clean the web application project area (optional).
- Execute the command asant clean to clean the web application.
Deploying the Sample Application
In this section, you will learn how to deploy the Caching Web sample application.Deploying the pre-built webapps-caching.war file is simple. you may deploy by either Using the asant script or by Using the asadmin command.
- Go to the src directory of the sample. For example:
- <install_root>/samples/webapps/caching/src
- Run asant using deploy task. For example:
- %asant deploy
Note You must run asant undeploy before redeploying this sample. This will ensure that all modules are undeployed and the resources are disabled.
The deployment process involves the following operations:
- Go to <install_root>/samples/webapps/caching/
- asadmin deploy --user <user-name> --password <password> --host <hostname> --port <admin-port> --type web webapps-caching.war
If you would like to verify the registration of the application, you may proceed to Verifying Deployment. Otherwise, proceed to Running the Sample Application.
- Authenticates against the local application server's administrative server
- The WAR file is transferred to the administrative server
- The administrative server begins the registration process:
Verifying Deployment
As an optional step, you can use the Application Server Administration Tool to verify that the application has been registered. Otherwise, proceed directly to Running the Sample Application.To verify the registration of the application, do the following:
Execute the command asadmin to look at applications deployed with a server instance. For example:
asadmin list-components --user <user-name> --password <password> --host <hostname>
You will see the webapps-caching module displayed as one of the listed components.
Undeploy the application
If you wish to undeploy the application after successful deployment, you may do so by either Using the asant script or by Using the asadmin command.
- Go to <install_root>/samples/webapps/caching/src
- asadmin undeploy --user <user-name> --password <password> --host <hostname> --port <admin-port> --type web webapps-caching
Running the Sample Application
You may run the appliction through the following URL:http://<AppServer hostname>:<port>/webapps-caching/index.html
Servlet Caching: Based on the sun-web.xml, the results are cached if the Input String is either "one" or "two" no matter if the Delivery Mechanism is "Servlet Only" or "Via JSP". If you like to turn the cache off or change the cache time-out value , you can achieve it by modifying the attributes of the cache element in sun-web.xml. You must undeploy, rebuild the application and then redeploy.
Troubleshooting
If you encounter problems when running the application, review the log files at <install_root>/domains/<domain-instance>/logs/server.log to learn what exactly went wrong.
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
Last
Updated October 2, 2003