You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ed Wolpert <wo...@radiancegroup.com> on 2000/02/02 00:52:09 UTC

RE: Session Created by XSP? [Problems with xsp-java.xsl]

I don't understand why XSP requires the session? Does it need it?
For the app we're developing, we want to control session creation... 
and this will most likely cause us problems. Does anyone know why 
this is needed for XSP?

If it's not needed, what needs to happen to change this in the
source?

-----Original Message-----
From: Mike Engelhart [mailto:mengelhart@earthtrip.com]
Sent: Tuesday, February 01, 2000 4:35 PM
To: cocoon-users@xml.apache.org
Subject: Re: Session Created by XSP? [was RE: redirect]


Ed Wolpert wrote:

> I just updated my system to try this... but I got behavior that I didn't
> expect. Basically, if the user's session doesn't exist (timeout, not
> created,etc) I want to redirect. The XSP technique to redirect works,
> however, now it seems that the session is created after the redirection.
> Does this sound correct? (Is this a feature versus bug versus user error)

I was looking through the source code and unfortunately the xsp-java.xsl
file has the following it in it.   I don't understand why this is there
except so that maybe XSP's have access to the session object but why it
creates one for you I don't understand.

Mike

**********from xsp-java.xl********************
    // Make session object readily available
        HttpSession session = request.getSession(true);

        <xsl:for-each
select="/processing-instruction()[not(contains(.,'xsp'))]">
          document.appendChild(
            document.createProcessingInstruction(
              "<xsl:value-of select="name()"/>",
              "<xsl:value-of select="."/>"
            )
          );
        </xsl:for-each>

Re: Session Created by XSP? [Problems with xsp-java.xsl]

Posted by Eric SCHAEFFER <es...@posterconseil.com>.
----- Original Message -----
From: Mike Engelhart <me...@earthtrip.com>
To: <co...@xml.apache.org>
Sent: Wednesday, February 02, 2000 5:09 PM
Subject: Re: Session Created by XSP? [Problems with xsp-java.xsl]

>
> I think we could add something like what JSP does in the page directive
> like:
>
> <xsp:page language="java" session=true
> xmlns:xsp="http://www.apache.org/1999/XSP/Core">
>
> this would then create a session if one wasn't already created.
>

+1

> We'll have to wait for Ricardo to see what he thinks...
>
> Mike
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>

_______________________________________

Eric SCHAEFFER
eschaeffer@posterconseil.com

POSTER CONSEIL
118 rue de Tocqueville
75017 PARIS
FRANCE
Tel. : 33-140541058
Fax : 33-140541059

----------------------------------------------------------------------------
-----------------------------
 Come to the first official Apache Software Foundation Conference!
-----------------------------------
http://ApacheCon.Com ------------------------------------
_______________________________________



Re: Session Created by XSP? [Problems with xsp-java.xsl]

Posted by Mike Engelhart <me...@earthtrip.com>.
Eric SCHAEFFER wrote:

> I meant changing the xsl file in the jar (or create a new one and change the
> cocoon.properties, but of course for all XSP pages).
> 
> Sessions are a problem. There's the notion of 'creation', and therefor an
> xsp tag for creating a new session should exist. Or maybe better, a tag for
> making the session object available with creation (getSession(true)) or
> without creation (getSession(false)).
> 
> But it must be changed in the XSP 'Core' stylesheet.
> 
> 
> Eric.
Sorry, thought you meant just changing it in each page :-)

I think we could add something like what JSP does in the page directive
like:

<xsp:page language="java" session=true
xmlns:xsp="http://www.apache.org/1999/XSP/Core">

this would then create a session if one wasn't already created.

We'll have to wait for Ricardo to see what he thinks...

Mike


Re: Session Created by XSP? [Problems with xsp-java.xsl]

Posted by Eric SCHAEFFER <es...@posterconseil.com>.
I meant changing the xsl file in the jar (or create a new one and change the
cocoon.properties, but of course for all XSP pages).

Sessions are a problem. There's the notion of 'creation', and therefor an
xsp tag for creating a new session should exist. Or maybe better, a tag for
making the session object available with creation (getSession(true)) or
without creation (getSession(false)).

But it must be changed in the XSP 'Core' stylesheet.


Eric.

_______________________________________

Eric SCHAEFFER
eschaeffer@posterconseil.com

POSTER CONSEIL
118 rue de Tocqueville
75017 PARIS
FRANCE
Tel. : 33-140541058
Fax : 33-140541059

----------------------------------------------------------------------------
-----------------------------
 Come to the first official Apache Software Foundation Conference!
-----------------------------------
http://ApacheCon.Com ------------------------------------
_______________________________________

----- Original Message -----
From: Mike Engelhart <me...@earthtrip.com>
To: <co...@xml.apache.org>
Sent: Wednesday, February 02, 2000 4:29 PM
Subject: Re: Session Created by XSP? [Problems with xsp-java.xsl]


> Eric SCHAEFFER wrote:
>
> > just:
> >
> > HttpSession session = request.getSession(false);
> >
> >
> > If you ask for the session this way and if the client doesn't have a
> > session, it will return null without creating a new one. Isn't it
enougth ?
> >
> > Eric.
> That's not the solution. The issue is that the xsp-java.xsl file that is
in
> the Cocoon.jar file (this file is the template used to create the compiled
> XSP classes) hardcodes this:
> HttpSession session = request.getSession(true);
>
> in the template so that unless you go into the jar file and change it to
> false, ALL XSP pages create a session whether you want one or not.  This
> needs to be changed.  It would be trivial to do what JSP does and have a
tag
> of some sort that determines session creation.
> I personally can't wait and changed the xsl file in Cocoon to this:
> HttpSession session = request.getSession(false);
>
> This way it doesn't break the code that relies on the session object being
> there and also doesn't implicitly create a new session.  I think Ricardo
put
> it there so that the XSP page could use the "session" variable without
> having to declare it.
>
> Mike
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>


Re: Session Created by XSP? [Problems with xsp-java.xsl]

Posted by Mike Engelhart <me...@earthtrip.com>.
Eric SCHAEFFER wrote:

> just:
> 
> HttpSession session = request.getSession(false);
> 
> 
> If you ask for the session this way and if the client doesn't have a
> session, it will return null without creating a new one. Isn't it enougth ?
> 
> Eric.
That's not the solution. The issue is that the xsp-java.xsl file that is in
the Cocoon.jar file (this file is the template used to create the compiled
XSP classes) hardcodes this:
HttpSession session = request.getSession(true);

in the template so that unless you go into the jar file and change it to
false, ALL XSP pages create a session whether you want one or not.  This
needs to be changed.  It would be trivial to do what JSP does and have a tag
of some sort that determines session creation.
I personally can't wait and changed the xsl file in Cocoon to this:
HttpSession session = request.getSession(false);

This way it doesn't break the code that relies on the session object being
there and also doesn't implicitly create a new session.  I think Ricardo put
it there so that the XSP page could use the "session" variable without
having to declare it.

Mike


Re: Session Created by XSP? [Problems with xsp-java.xsl]

Posted by Eric SCHAEFFER <es...@posterconseil.com>.
just:

HttpSession session = request.getSession(false);


If you ask for the session this way and if the client doesn't have a
session, it will return null without creating a new one. Isn't it enougth ?

Eric.

_______________________________________

Eric SCHAEFFER
eschaeffer@posterconseil.com

POSTER CONSEIL
118 rue de Tocqueville
75017 PARIS
FRANCE
Tel. : 33-140541058
Fax : 33-140541059

----------------------------------------------------------------------------
-----------------------------
 Come to the first official Apache Software Foundation Conference!
-----------------------------------
http://ApacheCon.Com ------------------------------------
_______________________________________

----- Original Message -----
From: Mike Engelhart <me...@earthtrip.com>
To: <co...@xml.apache.org>
Sent: Wednesday, February 02, 2000 12:57 AM
Subject: Re: Session Created by XSP? [Problems with xsp-java.xsl]


> Ed Wolpert wrote:
>
> > I don't understand why XSP requires the session? Does it need it?
> > For the app we're developing, we want to control session creation...
> > and this will most likely cause us problems. Does anyone know why
> > this is needed for XSP?
> >
> > If it's not needed, what needs to happen to change this in the
> > source?
> >
> The other thing is try changing it and see what happens. I was thinking of
> changing it to just
> HttpSession session = null;
>
> and then calling using session = request.getSession(true);
>
> mike
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>


Re: Session Created by XSP? [Problems with xsp-java.xsl]

Posted by Mike Engelhart <me...@earthtrip.com>.
Ed Wolpert wrote:

> I don't understand why XSP requires the session? Does it need it?
> For the app we're developing, we want to control session creation...
> and this will most likely cause us problems. Does anyone know why
> this is needed for XSP?
> 
> If it's not needed, what needs to happen to change this in the
> source?
> 
The other thing is try changing it and see what happens. I was thinking of
changing it to just
HttpSession session = null;

and then calling using session = request.getSession(true);

mike


Re: Session Created by XSP? [Problems with xsp-java.xsl]

Posted by Mike Engelhart <me...@earthtrip.com>.
Ed Wolpert wrote:

> I don't understand why XSP requires the session? Does it need it?
> For the app we're developing, we want to control session creation...
> and this will most likely cause us problems. Does anyone know why
> this is needed for XSP?
> 
> If it's not needed, what needs to happen to change this in the
> source?
I don't think that XSP "needs" it but more that to allow access to the
session inside of an XSP, it was created and a reference to it is accessed.
Either way it's a hassle. I'll ask Ricardo when he's available

Mike