OracleAS Web Cache How-to

Date: September 12, 2003

How to use JESI control/include model to cache dynamic content

After completing this How-To you should be able to:
  •   Know about the JESI control/include model to cache dynamic content
  •   Use <jesi:control>, <jesi:include>, <jesi:param> tags

Introduction

Oracle JESI tag library provides convenient interface to ESI tags and Edge Sides Include functionality for Web caching. It provides two models to cache dynamic content.

  • Control/ Include model
  • Template/ Fragment model

This How-To explains the Control/Include model. In the control/ include model, the cacheable content is aggregated as included pages from a top level page. The control/ include model is used as follows:

  • The top level page is cached using the <jesi:control> tag
  • From the top level page, the content is aggregated using the <jesi:include> tag.
  • While aggregating the content, the top level page and the included pages are treated as individual documents. Hence, the included pages can be cached separately using the <jesi:control> tag.

The example depicts the employee information system. It accepts employee number and displays employee information for the given employee. After generating the dynamic content for the given employee, the content can be cached and served from the cache until it is invalidated. Following table lists the web pages used in this sample and describes control/include model.

jesiinclude.html Query page, which accepts employee number to fetch details about the employee. Submit request from this page is sent to empdetails.jsp.
empdetails.jsp

This page is the top level page, which displays employee information. This dynamic page can be cached once the content for the particular employee is generated. <jesi:control> tag is used to cache this document. The expiration value specifies how long the cached document should stay in the cache. The maxRemovalDelay specifies how long the cached content can be served stale after expiration.

<jesi:control cache="yes" expiration="60" maxRemovalDelay="60"/>

While caching this page, the combination of the URL and the post request (for eg. http://xyz.com/jesiinclude/empdetails.jsp POST;;;empno=7369;;) will be used as the cache key for the document.. For any other employee say, emp no=7566, the content will be generated again and cached.

From the top level page, the aggregate pages are included using the <jesi:include> tag. JSP parameter values are passed to the aggregate page using the <jesi:param> tag.

<jesi:include page="empinfo.jsp">
   <jesi:param name="empno" value="<%=empno%>"/>
</jesi:include>

 

empinfo.jsp This page is the aggregate page. This is included from the empdetails.jsp top level page. The aggregate pages are treated as separate documents. <jesi:control> tag is used in this page to cache this document.

Pre-requisites for running the example

You will need the following to run this example -

  • Oracle Application Server (9.0.3 or above). This can be downloaded from here
  • Oracle JDeveloper (9.0.3 or above). This can be downloaded from here. This is optional and required only if you wish to deploy from JDeveloper.

Deploying the Sample

The complete source code for this sample is available here. This section discusses the instruction to run the sample application

Step 1 Unjar jesiinclude.jar using Winzip, or using the following command:

> jar xvf jesiinclude.jar

This creates a directory jesiinclude.

Step 2

If you are using JDeveloper then, follow these steps

  • Open Oracle9i JDeveloper and use File/Open option to select the jesiinclude.jws from the jesiinclude directory.
  • Next, select Project/Make jesiinclude.jpr from main menu.
  • Create an application server connection
    • Go to Connections -> Application Server Connection. Right Click and click New connection..
    • In step 1, enter connection name and select Oracle9i Application Server
    • In step 2, enter user name and password
    • In step 3, enter Enterprise Manager's host name, port number and Remote Oracle AS home directory(required only if deployed on remote machine).
    • In step 4, click Next and Test the connection. Click Finish button.
  • Now, Right click jesiinclude.deploy and select Deploy to <connection name>, to the application server connection, which you have created in the previous step.
Step 3 To deploy the application using EM. follow the steps.
  • Go to EM web site -> default oc4j home.,
  • Choose Deploy EAR file
  • Enter J2EE Application name, Click the Browse button and choose jesiinclude.ear from <SAMPLE_HOME>/deploy/jesiinclude.ear
  • Enter the Application name as jesiinclude and click next
  • Enter URL mapping as /jesiinclude and click Finish
  • Click Deploy to deploy the application.

Running the Sample

Access the page on the browser, using the following URL

http://<host_name>:<port>/jesiinclude/jesiinclude.html

where, <host_name> is the machine on which Web Cache is installed and <port> is the port on which Web Cache listener is running.

For Example, http://incq185b.idc.oracle.com:7777/jesiinclude/jesiinclude.html

Resources


Please enter your comments about this sample in the OTN Sample Code Discussion Forum.


E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy