Home


Caching with Struts

Another important technology framework for WebSphere Commerce is Struts. As of version 6.0, WebSphere Commerce has moved from its proprietary model-view-controller implementation to the Struts open source implementation, developed by the Apache Software Foundation. Struts is a well-documented framework for J2EE Web application development, and has become an industry standard for deploying model-view-controller applications.

For more information on Struts, see: http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=/com.ibm.commerce.developer.doc/concepts/csdstrutskeycompons.htm


Using WebSphere Application Server prior to version 6.0

In the previous version of WebSphere Application Server, only one cache entry per servlet was supported, as shown in Example | -3. However, when you are using Struts, every request that ends in .do maps to the same ActionServlet servlet. To cache Struts responses, write a cache policy for the ActionServlet servlet based on its servlet path.

For example, consider two Struts actions: /HelloParam.do and /HelloAttr.do. To cache the responses based on the id request parameter and the arg request attribute respectively, use the cache policy shown in Example | -3.

Example 5-3 Single cache entry for multiple Struts actions

<cache-entry>
  <class>servlet</class>
  <name>org.apache.struts.action.ActionServlet.class</name>
  <cache-id>
    <component id="" type="servletpath">
      <value>/HelloParm.do</value>
    </component>
  </cache-id>
  <cache-id>
    <component id="" type="servletpath">
      <value>/HelloAttr.do</value>
    </component>
    <component id="arg" type="attribute">
      <required>true</required>
    </component>
  </cache-id>
</cache-entry>


Using WebSphere Application Server, v6.0 or later

The current version of WebSphere Application Server is capable of mapping multiple cache entries per servlet. The cache policy in Example | -3 has been rewritten in Example | -4 with more than one cache-entry.

Example 5-4 Multiple cache entries for each Struts action

<cache-entry>
  <class>servlet</class>
  <name>/HelloParam.do</name>
  <cache-id>
    <component id="id" type="parameter">
      <required>true</required>
    </component>
</cache-entry>
<cache-entry>
  <class>servlet</class>
  <name>/HelloAttr.do</name>
  <cache-id>
    <component id="arg" type="attribute">
      <required>true</required>
    </component>
  </cache-id>
</cache-entry>

+

Search Tips   |   Advanced Search