
<%@ page import="examples.*" errorPage="error.jsp" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/jwcache.tld" prefix="ojsp" %>

<ojsp:useCacheObj id="a1" policy="/WEB-INF/test-policy.cpd" 
  cacheScope="application" type="examples.WStrArray" >
<%
   a1=new WStrArray(4);
   a1.setStr(2,request.getParameter("testing4"));
   a1.setStr(1,"abc");
   a1.setStr(0, (new java.util.Date()).toString() );
   // storing the a1 into pagecontext
   // so useCacheObj tag can pick it up
   pageContext.setAttribute("a1",a1);
%> 
</ojsp:useCacheObj>
<%
   a1.setStr(3, (new java.util.Date()).toString() );
%>
<pre>
a1: (writeable a1 is cloned for every cache operation)
<%= a1 %>
<%= a1.getInfo() %>
</pre>

<ojsp:useCacheObj id="a2" policy="/WEB-INF/test-policy.cpd" 
  type="examples.RStrArray" >
<%
   // create a temp writeable array 
   WStrArray tmpa2=new WStrArray(3);
   tmpa2.setStr(2,request.getParameter("testing4"));
   tmpa2.setStr(1,"def");
   tmpa2.setStr(0, (new java.util.Date()).toString() );
   // create a readonly copy for the cache
   a2=new RStrArray(tmpa2);  
   // storing the a2 into pagecontext
   // so useCacheObj tag can pick it up
   pageContext.setAttribute("a2",a2);
%>
</ojsp:useCacheObj>

<pre>
a2: (readonly a2 is not cloned)
<%= a2 %>
<%= a2.getInfo() %>
</pre>

