Caching Web Sample Application |
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/apps/caching/javadocs/index.html after it is generated.
<install_root>/bin
is on your path. <install_root>/samples/webapps/apps/caching
,
execute the command asant
This command will execute the default target core to build the WAR file.
asant clean
to clean the web 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.
src
directory of the sample. For example,
<install_root>/samples/webapps/apps/caching
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.
<install_root>/samples/webapps/apps/caching
asadmin deploy --user <user-name>
--password <password> --host <hostname> --port <admin-port>
--type web webapps-caching.war
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.
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.
asant undeploy
<install_root>/samples/webapps/apps/caching
asadmin undeploy --user <user-name> --password <password> --host <hostname>
--port <admin-port> --type web webapps-caching
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.