You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Torsten Curdt <tc...@dff.st> on 2000/06/20 13:01:06 UTC

session obj

Since I'm new to cocoon I have some problems
starting...

I was trying to print out the session id of
the users session but I ran into the following
problem. Where will my <xsp:logic> be inserted?!
I need to get the http request and response objects
from cocoon.

just this...
    <xsp:logic>
       HttpSession session;
       session = request.getSession(true);
       ..

...don't work

Where will my code reside?
--
Torsten

Re: session obj

Posted by Giacomo Pati <Gi...@pwr.ch>.
On Tue, Jun 20, 2000 at 01:11:51PM +0200, Torsten Curdt wrote:
> > >     <xsp:logic>
> > >        HttpSession session;
> > >        session = request.getSession(true);
> > 
> > You should use another name for a new session, because "session" is the
> > name of the current session.
> 
> So I could just use..
> 
>    id = session.getId();
>    last = new Date(session.getLastAccessedTime());

Or use the session taglibs.

Giacomo

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1 856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1 856 2201
Hintereichenstrasse 7                     Mailto:Giacomo.Pati@pwr.ch
CH-8166 Niederweningen                    Web:   http://www.pwr.ch


Re: session obj

Posted by Morten Primdahl <mo...@caput.com>.
Torsten Curdt wrote:
> 
> Doesnt work either... this is my xsp page

Hi. Exactly how doesn't it work? Did you read 
http://xml.apache.org/cocoon/xsp.html ?
Try search for "session" in that page, the session
object should be accessible within your page. 

Morten

-- 
Morten Primdahl		Caput ApS	Tel +45 33 12 24 42		
morten@caput.com	Nygade 6	Fax +45 33 91 24 42
http://www.caput.com	DK-1164 Kbh K

RE: session obj

Posted by Torsten Curdt <tc...@dff.st>.
[snip]
> No, it was meant to be:
> <xsp:page language="java"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core">
>   <root>
>     <xsp:logic>
>      session = request.getSession(true);
>      ...
>     </xsp:logic>
>
>   <root>
> </xsp:page>
> Everything before the <root> tag is class level code (where you define
> local methods or global variables). Everything inside the <root> tags is
> the actual method which generate the page and has access to the request
> object. BTW <root> can be called whatever you like it. It is known as
> the root tag because its the top most element byside the xsp namespace
....this's what I made out of it.
But that gives me an "DOM006 Hierarchy request error"!
Here we go...

<xsl:template match="page">
..
[snip]
...
<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
    <xsp:logic>
       HttpSession mysession;
       static private int counter = 0;

       private synchronized int getCount(){
         return counter++;
       }

       private String getDescription(){
	 String s;
         s = "session id = " + mysession.getId() + "&lt;br&gt;" +
             "session is new = " + mysession.isNew() + "&lt;br&gt;" +
             "session creation time = " + new
Date(mysession.getCreationTime()) + "&lt;br&gt;" +
             "session last access = " + new
Date(mysession.getLastAccessedTime()) + "&lt;br&gt;" ;
         return(s);
       }
    </xsp:logic>
    <root>
      <xsp:logic>
         mysession = request.getSession(true);
      </xsp:logic>
    </root>
    <xsl:copy>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsp:page>
</xsl:template>

What did I get wrong now ?!
--
Torsten


Re: session obj

Posted by Giacomo Pati <Gi...@pwr.ch>.
Torsten Curdt wrote:
> 
> > > Doesnt work either... this is my xsp page
> > Because you didn't put it in the root tag, as I said, but into the
> > xsp:page tag. As stated in the docs, the root tag must be the only child
> > of the xsp:page tag. Also, you can look at the generated Java source
> > code, it is in your repository.
> Me idot overread the root tag but all documentation I found was
> http://xml.apache.org/cocoon/xsp.html and the API docs in the docs
> dir of the contribution. Did I miss some documentation?!
> 
> Anyway in the above page it says...
> 
> ...
> The following objects are accesible inside an XSP page:
> * session. The standard HttpSession servlet object.
>   This object is typically used to store data associated with a user HTTP
> session
> ...
> 
> So you mean this should do it?...
> 
> <xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
>   <xsp:root>
>     <xsp:logic>
>      session = request.getSession(true);
>      ...
>     </xsp:logic>
> 
>   </xsp:root>
> </xsp:page>

No, it was meant to be:

<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core">
  <root>
    <xsp:logic>
     session = request.getSession(true);
     ...
    </xsp:logic>

  <root>
</xsp:page>

Everything before the <root> tag is class level code (where you define
local methods or global variables). Everything inside the <root> tags is
the actual method which generate the page and has access to the request
object. BTW <root> can be called whatever you like it. It is known as
the root tag because its the top most element byside the xsp namespace.

Giacomo

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1 856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1 856 2201
Hintereichenstrasse 7                     Mailto:Giacomo.Pati@pwr.ch
CH-8166 Niederweningen                    Web:   http://www.pwr.ch

RE: session obj

Posted by Torsten Curdt <tc...@dff.st>.
> > Doesnt work either... this is my xsp page
> Because you didn't put it in the root tag, as I said, but into the
> xsp:page tag. As stated in the docs, the root tag must be the only child
> of the xsp:page tag. Also, you can look at the generated Java source
> code, it is in your repository.
Me idot overread the root tag but all documentation I found was
http://xml.apache.org/cocoon/xsp.html and the API docs in the docs
dir of the contribution. Did I miss some documentation?!

Anyway in the above page it says...

...
The following objects are accesible inside an XSP page:
* session. The standard HttpSession servlet object.
  This object is typically used to store data associated with a user HTTP
session
...

So you mean this should do it?...

<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
  <xsp:root>
    <xsp:logic>
     session = request.getSession(true);
     ...
    </xsp:logic>

  </xsp:root>
</xsp:page>

But I cannot put another logic tag into the page tag?!
d*mn ... were do I find such information for myself ?!?!

cheers
--
Torsten


Re: session obj

Posted by Ulrich Mayring <ul...@denic.de>.
Torsten Curdt wrote:
> 
> Doesnt work either... this is my xsp page

Because you didn't put it in the root tag, as I said, but into the
xsp:page tag. As stated in the docs, the root tag must be the only child
of the xsp:page tag. Also, you can look at the generated Java source
code, it is in your repository.

Ulrich

-- 
Ulrich Mayring
DENIC eG, Systementwicklung

RE: session obj

Posted by Torsten Curdt <tc...@dff.st>.
Doesnt work either... this is my xsp page
  <xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
    <xsp:logic>
       /* in which obj will this stuff reside ??????*/
       /* directly in a derived class of HttpServlet ??? */

       static private int counter = 0;
       private synchronized int incCount(){
         return counter++;
       }
       private String getDescription(){
         /* how to get my session or request obj ???????! */
	   String s;
         s = "session id = " + session.getId() + "&lt;br&gt;" +
             "session is new = " + session.isNew() + "&lt;br&gt;" +
             "session creation time = " + new
Date(session.getCreationTime()) + "&lt;br&gt;" +
             "session last access = " + new
Date(session.getLastAccessedTime()) + "&lt;br&gt;" ;
         return(s);
       }
    </xsp:logic>
    <xsl:copy>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsp:page>

...so where exactly get I the objects I need?!
--
Torsten


RE: session obj

Posted by Michele Bianchi <mi...@research.telcordia.com>.
On Tue, 20 Jun 2000, Torsten Curdt wrote:

> > >     <xsp:logic>
> > >        HttpSession session;
> > >        session = request.getSession(true);
> > 
> > You should use another name for a new session, because "session" is the
> > name of the current session.
> 
> So I could just use..
> 
>    id = session.getId();
>    last = new Date(session.getLastAccessedTime());
> 
> ...and so on?!

first of all you have to create a session somewhere (in some xsp page):

<xsp:logic>
 session = request.getSession(true);
 ...

then cocoon gets automatically the session (somewhere
request.getSession(false)).



-------------------------------------------------------------------------------
michele_bianchi                                  exsense | integrated_solutions
phone://+39_348_7651874                                       via_scrimiari_45b
http://mic.aesthetica.it                                     37132_verona_italy


RE: session obj

Posted by Torsten Curdt <tc...@dff.st>.
> >     <xsp:logic>
> >        HttpSession session;
> >        session = request.getSession(true);
> 
> You should use another name for a new session, because "session" is the
> name of the current session.

So I could just use..

   id = session.getId();
   last = new Date(session.getLastAccessedTime());

...and so on?!
--
Torsten

Re: session obj

Posted by Ulrich Mayring <ul...@denic.de>.
Torsten Curdt wrote:
> 
>     <xsp:logic>
>        HttpSession session;
>        session = request.getSession(true);

You should use another name for a new session, because "session" is the
name of the current session.

Put your <xsp:logic> block within the root-tag of your page, which is
right inside the <xsp:page> tag.

Ulrich

-- 
Ulrich Mayring
DENIC eG, Systementwicklung