AW: [opencms-dev] Sharing state across included JSPs

Jonathan Woods jonathan.woods at scintillance.com
Wed Mar 1 14:53:33 CET 2006


For what it's worth, problem solved - I was making a dumb mistake.  You can
set request attributes (as opposed to parameters) to any kind of Object you
like, and retrieve them in subsequently executed page elements.  I'd tried
to retrieve mine before the <cms:include> invocation, but now that I've put
things in the right order it all works fine.
 
Jon

  _____  

From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Jonathan Woods
Sent: 28 February 2006 20:09
To: 'The OpenCms mailing list'
Subject: [opencms-dev] Sharing state across included JSPs


I have a JSP template which uses <cms:include> to include a couple of other
JSP page elements (header and footer, predictably enough).  I create an
object or two in the header which I need to use in the page body and in the
footer, but at the moment I'm struggling to see how I can share the object
reference:
 
1.  Putting it into the page context, either via Java
(pageContext.setAttribute()) or via <jsp:useBean>, doesn't seem to work - I
guess this is because the 'include' is dynamic and we're dealing with
different Java scopes.
 
2. Same with the request context, again because the include is dynamic.
OpenCms documentation suggests that you can set request parameters before
executing the include, but from the taglib only String setting is possible -
and I want to share a reference to something other than a String.
 
3.  Putting it into session context is (i) a pity, because otherwise I don't
need to set up sessions and maintain session state, and (ii) not really
appropriate, because in theory the same client could make two requests so
quickly that two JSP-serving threads would hit the same session state.  I
realise there are ways round (ii), but I'd rather not go there if there's an
easier solution.
 
Any ideas welcomed.  I would really love to get on with some coding and stop
having to wrestle with the execution environment like this!
 
Jon
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060301/d0b39233/attachment.htm>


More information about the opencms-dev mailing list