You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Harald Kornfeil <Ha...@gmx.at> on 2000/09/13 22:02:49 UTC
BTW: buggy??? (was: Re: Cocoon session)
At 21:36 13.09.00 +0800, "HuiSion Teh" <hu...@magix.com.sg> wrote:
>hi I understand that cocoon tag session is a wrapper on the servlet session
>api. I have read books that cookies, hidden fields, uri rewriting, servlet
>session api are means to track session.
>
>Am I correct to say that:
>1. the servlet session api is the one I should use in a servlet/cocoon
>environment. Like "an ultimate, easy to use session tracking method"?
Well, yes - if you like to call it that way ;-)
>2. we do not have to concern if cookies is enabled or not when servlet
>session api is used? That means it will work independent of cookies setting?
No - I would say that the server has no means to know which
session-object coresponds with which Request -> so if you want to
be sure you have to use URL-Rewriting (servlet-API: javax.servlet.http
Interface HttpServletResponse: String response.encodeURL(String url) )
or Hidden Fields.
But I havent unsed either of them so far with cocoon ... sorry :-(
Harald
BTW: sometimes I get java.lang.NullPointerException
when I am using the session-object??
Anyone who knows why? Or am I doing here something very stupid? :-\
it also happens when accessing the following (Ricardo Rochas) URL
http://www.plenix.com/xsp/samples/redirect.xml
also defining a new session-object (e.g. "hsession") works (of course ;-) )
e.g.:
does not work:
<xsp:logic>
<![CDATA[
Integer ival = (Integer) session.getValue("sessiontest.counter");
if (ival==null) ival = new Integer(1);
else ival = new Integer(ival.intValue() + 1);
session.putValue("sessiontest.counter", ival);
]]>
</xsp:logic>
my workaround:
<xsp:logic>
<![CDATA[
// REdefine (!!) session to avoid Null-Pointer-Exception!?
if (session == null) session = request.getSession(true);
Integer ival = (Integer) session.getValue("sessiontest.counter");
if (ival==null) ival = new Integer(1);
else ival = new Integer(ival.intValue() + 1);
session.putValue("sessiontest.counter", ival);
]]>
</xsp:logic>
my system: redhat linux 6.2, sun jdk 1.2.2, tomcat 3.1, cocoon 1.7.4