[opencms-dev] Dynamic Pages (template cache)

Ivan Biddles ivanb at scientology.net
Wed Jan 22 21:16:33 CET 2003


Alex,

I wonder if the way that I have structured my JSPs may have something to
do with the fact that my pages are not appearing dynamic.

I have my control page in a /cos directory from the root, but my JSPs
are in a directory like /system/modules/cos/elements/.

Does OpenCms consider anything inside such a directory to be a
candidiate for storing in this "template cache"?

Should I therefore move my JSPs to the same folders as the control pages
with invoke them, as your small test sample did?

Best wishes,
             Ivan

-----Original Message-----
From: owner-opencms-dev at www.opencms.org
[mailto:owner-opencms-dev at www.opencms.org] On Behalf Of Ivan Biddles
Sent: Monday, January 20, 2003 13:27
To: opencms-dev at www.opencms.org
Subject: RE: [opencms-dev] Dynamic Pages (template cache)

I really appreciate your help, Alex. I will try out your test sample and
I'll also send your more of my code.

Thanks,
        Ivan

-----Original Message-----
From: owner-opencms-dev at www.opencms.org
[mailto:owner-opencms-dev at www.opencms.org] On Behalf Of Alexander
Kandzior
Sent: Monday, January 20, 2003 12:44
To: opencms-dev at www.opencms.org
Subject: RE: [opencms-dev] Dynamic Pages (template cache)

Ivan,

everything looks o.k. here. No obvious things I would do differently.
Actually, the approach works for me. Please check out the following -
Create two files like:

test.html (type page):
------
<?xml version="1.0" encoding="utf-8"?>
<PAGE>
    <class>com.opencms.template.CmsXmlTemplate</class>
 
<masterTemplate>/system/modules/org.opencms.default/templates/empty</mas
terTemplate>
    <ELEMENTDEF name="body">
        <CLASS>com.opencms.flex.CmsJspTemplate</CLASS>
        <TEMPLATE>test.jsp</TEMPLATE>
    </ELEMENTDEF>
</PAGE>
-------

test.jsp (same directory, type jsp):
-------
<h2><%= new java.util.Date() %></h2>
-------

And publish this. The date should be updated/changed every time the page
"test.html" is requested (it is for me). If this is the case, maybe it's
somehow connected to your mastertemplate. Feel free to send more code if
required.


Best Regards,
Alex.

Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com

> -----Original Message-----
> From: owner-opencms-dev at www.opencms.org 
> [mailto:owner-opencms-dev at www.opencms.org] On Behalf Of Ivan Biddles
> Sent: Monday, January 20, 2003 7:24 PM
> To: opencms-dev at www.opencms.org
> Subject: RE: [opencms-dev] Dynamic Pages (template cache)
> 
> 
> Thanks, Alex.
> 
> Each page has two JSPs associated with it - one for 
> displaying the page, and the second for routing the incoming 
> requests from that page.
> 
> Template
> --------
> 
> <?xml version="1.0" encoding="utf-8"?>
> <PAGE>
>     <class>com.opencms.template.CmsXmlTemplate</class>
>     <masterTemplate>/system/modules/.../Master</masterTemplate>
>     <ELEMENTDEF name="body">
>         <CLASS>com.opencms.flex.CmsJspTemplate</CLASS>
>         <TEMPLATE>/system/modules/.../Register1Display.jsp</TEMPLATE>
>     </ELEMENTDEF>
> </PAGE>
> 
> Display JSP:
> ------------
> 
> (LinkResolver is just a class with a static method which 
> wraps LinkSubstitution.getLinkSubstitution, from before the 
> latter became a static method.)
> 
> <%
>    CmsObject myCmsObject  = ((CmsFlexRequest) 
> request).getCmsObject ();
>    String mySubmitJsp = LinkResolver.resolve (myCmsObject, 
> "/..../ Register1Submitter.jsp "); %>
> 
> <form method="post" name="register" action="<%=mySubmitJsp%>"> etc.
> 
> Routing JSP:
> -----------
> 
> It extracts the request data from the form, makes a back-end 
> validation call and then either proceeds to the next page or 
> redisplays the original page with an error message highlighted.
> 
> There is no HTML in this JSP at all.
> 
> <jsp:useBean       id="testBean" class="TestBean"    
> scope="session" />
> <jsp:setProperty name="testBean" property="*" /> 
> <%
>    String  myLinkPage = "";
>    boolean myIsValid  = testBean.validate ();
> 
>    if (myIsValid) {
>       myLinkPage = LinkResolver.resolve (request,
> "/..../register2.html");
>    }
>    else {
>       myLinkPage = LinkResolver.resolve (request,
> "/..../register1.html");
>    }
>    response.sendRedirect (myLinkPage);
> %>
> 
> Java Classes
> ------------
> 
> I use the normal CmsXmlTemplate class. My back-end classes 
> are called by the routing JSP, so they are not really relevant.
> 
> That is just about it. I have the control page for 
> "register1.html" set to "export=dynamic". (I need it to be 
> "export=https", but that's another issue I'm tracking down.)
> 
> Thanks for your help.
> 
> Best wishes,   Ivan
> 
> 
> -----Original Message-----
> From: owner-opencms-dev at www.opencms.org 
> [mailto:owner-opencms-dev at www.opencms.org] On Behalf Of 
> Alexander Kandzior
> Sent: Monday, January 20, 2003 09:53
> To: opencms-dev at www.opencms.org
> Subject: RE: [opencms-dev] Dynamic Pages (template cache)
> 
> Ivan,
> 
> I can assure you integrating dynamic parts from JSP in a 
> template is no general problem. Maybe it's in your way of 
> using the JSP integration. If you post the significant parts 
> from your template, JSP and your java classes here I will 
> take a look. 
> 
> Best Regards,
> Alex.
> 
> Alexander Kandzior
> Alkacon Software - The OpenCms Experts
> http://www.alkacon.com
> 
> > -----Original Message-----
> > From: owner-opencms-dev at www.opencms.org
> > [mailto:owner-opencms-dev at www.opencms.org] On Behalf Of Ivan Biddles
> > Sent: Monday, January 20, 2003 6:23 PM
> > To: opencms-dev at www.opencms.org
> > Subject: RE: [opencms-dev] Dynamic Pages (template cache)
> > 
> > 
> > Hi Christian,
> > 
> > Thanks, but I already do that. It is not the element cache
> > that is causing the problem - it is this "template cache".
> > 
> > I created my own subclass of CmsXmlTemplate just for the
> > purpose of trying to solve this problem. All it has is an 
> > override of the getCacheDirectives method in which I return 
> > "new CachDirectives(false)", as it says to do in the manual. 
> > But the manual also says that it is for the "element cache".
> > 
> > I have disabled the element cache, and added a logging line
> > to CmsObject that proves that the element cache reference 
> > returned from the "init" method is always null.
> > 
> > However nothing seems to turn off the "template cache", which
> > is hard-coded to create a cache of 1000 entries.
> > 
> > I have an ugly temporary workaround in that I have changed
> > the CmsTemplateCache "put" method to not store template 
> > content in the template cache if the supplied key matches one 
> > of my dynamic pages. This is the only thing I have found that 
> > stops the behaviour, but this cannot be the solution.
> > 
> > Can someone tell me how to turn this thing off selectively
> > and by configuration, or at least without having to change 
> > the OpenCms code?
> > 
> > Thanks,
> >          Ivan
> > 
> > -----Original Message-----
> > From: owner-opencms-dev at www.opencms.org
> > [mailto:owner-opencms-dev at www.opencms.org] On Behalf Of 
> > Hoffmann, Christian
> > Sent: Monday, January 20, 2003 00:39
> > To: 'opencms-dev at www.opencms.org'
> > Subject: AW: [opencms-dev] Dynamic Pages (template cache)
> > 
> > Hi Ivan,
> > 
> > maybe you should use getCacheDirectives()? It is described in
> > Section 2.3.9 (pages 63-69) in the Manual.
> > 
> > Christian
> > 
> > > -----Ursprüngliche Nachricht-----
> > > Von: Ivan Biddles [mailto:ivanb at scientology.net]
> > > Gesendet: Montag, 20. Januar 2003 09:17
> > > An: opencms-dev at www.opencms.org
> > > Betreff: [opencms-dev] Dynamic Pages (template cache)
> > > 
> > > 
> > > Hi,
> > > 
> > > I have been struggling with an issue that my dynamic pages are 
> > > generated once, when online, but then the JSPs are never 
> run again 
> > > and the same version is always displayed.
> > > 
> > > I have specified these pages as "export=dynamic", and everything 
> > > works perfectly in the off-line project.
> > > 
> > > I tracked it down to the "template cache". I had already tried 
> > > disabling both the element and flex caches without success.
> > > 
> > > (The template cache is only mentioned twice in the Manual, both 
> > > times in the Javadoc section - pages 200 and 215.)
> > > 
> > > What I found was that my JSP would run once and then its _output_ 
> > > would be stored in the template cache. From then on 
> OpenCms simply 
> > > serves up the page as it was originally created.
> > > 
> > > This means that Person A logs in and goes to some page and gets a 
> > > display of some personal information, let's say. Then 
> Person B does 
> > > the same thing but he sees Person A's information, 
> because OpenCms 
> > > is only se5rving up one version of this page.
> > > 
> > > In CmsTemplate Cache, I found the following code:
> > > 
> > >       // TODO: get the cache-size from properties
> > >       private CmsCache templateCache = new CmsCache(1000);
> > > 
> > > So there is no way to turn off this cache from the property file.
> > > 
> > > There must be some way of controlling this behaviour.
> > > 
> > > I'm sure others must tried to create dynamic pages, so it must be 
> > > some setting that I have got wrong somewhere, but I haven't been 
> > > able to find what it is.
> > > 
> > > So any help is urgently needed and would be greatly appreciated.
> > > 
> > > Thanks,
> > >            Ivan
> > > 
> > 
> 
> 





More information about the opencms-dev mailing list