cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miguel Angel Marín Moreno <>
Subject problem withs sessions running JSPs in COCOON (ver. 2.1.4)
Date Fri, 08 Apr 2005 09:21:00 GMT
Hi all!

I have a problem with essions in cocoon. In my pipeline I execute a 
piece of code in JSP using CINCLUDE transformer. In this piece of code I 
load some values in the session which ones later I need to get with 
executing another JSP. (I can't use cocoon's sessions/context because I 
can't get its values from the JSP code)

In other words, I'll try to explain it better with the code (read the 
comments please)

this is my pipeline:

<map:match pattern="Almacena.jsp">
      <map:generate type="request">
       <map:parameter name="generate-attributes" value="true"/>

<!-- the pipeline starts with an XML which contains the REQUEST details -->
<!-- peticion.xsl is an XSLT that transform the XML to set the correct 
params to apply the CINCLUDE with the params that identify the URL of 
the JSP file that I want to execute -->

        <map:transform src="xsl/peticion.xsl">
            <map:parameter name="cms-url"
            <map:parameter name="url-peticion" value="AlmacenaSession.jsp"/>

<!-- I've thought in the posibility of passing the SessionID as a 
parameter to the JSP, but don't know how to "set the sessionID" in JSP. 
Any idea?-->

<!-- When I apply the Cinclude transformer, the JSP code RUNS WITH A 
DIFFERENT SESSION EACH TIME (that's my problem!) -->

         <map:transform type="cinclude"/>

<!-- As I am only proving the way of doing this, I'm using a very simple 
  JSP file which set the values of 2 params (nombre, edad) in the 
session and returns an XML file which will be transformed by the XSLT 
"Almacena.xsl" -->

       <map:transform src="xsl/Almacena.xsl"/>

      <map:serialize type="html"/>

This is the piece of JSP code:

> <%@ page language="Java" session="true"%><?xml version="1.0"
> encoding="ISO-8859-1"?>
> <%@ page import="java.util.*" %>
> <%!String nombre;
>         Integer edad;
>         String sessionId; %>
>  <%nombre=request.getParameter("nombre");
>         edad=Integer.parseInt(request.getParameter("edad"));
>         sessionId = session.getId();
>         session.setAttribute("nombre",nombre);
>         session.setAttribute("edad",edad);%>
>     <AlmacenaEnSession>
>         <nombre><%=nombre%></nombre>
>         <edad><%=edad%></edad>
>         <sessionID><%=sessionId%></sessionID>
>     </AlmacenaEnSession>

I get the SessionID so I can prove that it's different of the one I have 
in the browser :((

Finally I try to recovery the info I've saved in the JSP session using 
another pipeline similar to this one which execute a JSP code too.
As the session in which the JSP runs is different each time I cannot get 
the values....

Any idea?

Thanks in advance!!

Miguel Angel Marín

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message