Remember that xsp (like jsp) gets compiled into a java class - a Cocoon Generator. In order to account for all the things people might want to do (define additional methods, etc) only the code inside the first tag gets placed inside the generate() method of the resulting generator. XSP defines some convenience member variables like "session", "request", etc. but they are not initiated yet when you are referring to them below.
This whole process might be a lot less mysterious if you go examine the .java file that is created from your xsp prior to compilation. It's probably under your servlet container's work directory under the cocoon-files directory. Dig around and you'll see a directory tree that starts with org/apache/cocoon/... look in there and you'll find it. HTH, Geoff Howard > -----Original Message----- > From: morten svanęs [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 12, 2003 4:13 PM > To: [EMAIL PROTECTED] > Subject: Re: can't resolve session in xsp > > > Hi all, > seems like I finaly found the solution myself. > Maybe it's pretty obvious but anyway. > It seems like you can't get session before > the first tag in a xsp. > > THIS DON'T WORK! ,reports "can't resolve session" > <xsp:page> > <xsp:logic> > String sessionvar = (String)session.getAttribute("foo"); > </xsp:logic> > > <tag> > </tag> > </xsp:page> > > THIS WORKS! > <xsp:page> > <xsp:logic> > > </xsp:logic> > > <tag> > <xsp:logic> > String sessionvar = (String)session.getAttribute("foo"); > </xsp:logic> > </tag> > </xsp:page> > > Can someone please explain to me why ? > > Morten Svanaes > > ----- Original Message ----- > From: "morten svanęs" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, June 12, 2003 10:44 AM > Subject: Re: can't resolve session in xsp > > > > Hi, > > I forgot to say the xsp called is called from within another xmlform > script. > > Seems like something happens when you use a xsp inside another match ? > > > > > > ----- Original Message ----- > > From: "morten svanęs" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Thursday, June 12, 2003 12:47 AM > > Subject: can't resolve session in xsp > > > > > > > Hi, > > > I'm getting a error mesage when I'm trying to access the session in > > > a xsp script and I don't understand why. > > > It happens when I'm trying to assign a session variable with > > > session.getAttribute to a another variable, but when I write > > > <xsp-session:get-attribute name="user"/> outside the <xsp:logic> > > > it works. > > > Here is the error message: > > > > > > org.apache.cocoon.ProcessingException: Failed to execute pipeline.: > > > org.apache.cocoon.ProcessingException: Language Exception: > > > org.apache.cocoon.components.language.LanguageException: > Error compiling > > > meny_xsp: > > > ERROR 1 (org\apache\cocoon\www\xmldbform\useradmin\meny_xsp.java): > > > ... > > > > > > String myvar = > > > > > > ( > > > > > > // start error (lines 81-81) "session cannot be resolved" > > > XSPSessionHelper.getSessionAttribute(session, > > > > > > // end error > > > String.valueOf("user"), > > > null) > > > ) > > > ; > > > > > > ... > > > Line 81, column 0: session cannot be resolved > > > > > > Here is a code snippet from my xsp file: > > > <xsp:logic> > > > String myvar = <xsp-session:get-attribute name="user"/>; > > > </xsp:logic> > > > > > > I'm running cocoon-2.1m2 > > > Any help or suggestions would be greatly appreciated. > > > > > > Regards > > > Morten Svanaes > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]