You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by morten svanæs <mo...@web-som-virker.no> on 2003/06/12 09:47:44 UTC

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: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


RE: can't resolve session in xsp

Posted by Geoff Howard <co...@leverageweb.com>.
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:morten@web-som-virker.no]
> Sent: Thursday, June 12, 2003 4:13 PM
> To: cocoon-users@xml.apache.org
> 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" <mo...@web-som-virker.no>
> To: <co...@xml.apache.org>
> 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" <mo...@web-som-virker.no>
> > To: <co...@xml.apache.org>
> > 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: cocoon-users-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: can't resolve session in xsp

Posted by morten svanæs <mo...@web-som-virker.no>.
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" <mo...@web-som-virker.no>
To: <co...@xml.apache.org>
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" <mo...@web-som-virker.no>
> To: <co...@xml.apache.org>
> 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: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: xsl:import question

Posted by Joerg Heinicke <jo...@gmx.de>.
Hello Markus,

no guarantee that it works, but what about the following:

<xsl:import href="cocoon:/trignm.xsl"/>

Now you must add a pipeline to your sitemap:

<map:match pattern="trignm.xsl">
   <map:read src="path/to/xsl/trignm.xsl" mime-type="text/xml"/>
</map:match>

With this solution you have added a further mapping layer: You can 
change the location of your trignm.xsl without changing the import 
statements in every refering stylesheet.

If you have different sub sitemaps, you can add the above pipeline to 
the root sitemap and change the import path to "cocoon://trignm.xsl" 
(double slash).

Another possibility is to use the context:// protocol which refers to 
the servlet context. Now you were working on the file system: 
"context://resources/stylesheets/trignm.xsl".

Find more about the cocoon protocols at 
http://cocoon.apache.org/2.0/userdocs/concepts/sitemap.html (in the 
middle of the page).

Joerg

Markus Alin wrote:
> Hi!!
> 
> I'm using a computational stylesheet with alot of trigonometry templates
> which I include into whatever style sheet which needs it with the
> <xsl:import> tag. I ofcourse want the computational stylesheet to be
> available all over the application and I don't want to keep duplicate
> copies of it. The only way i found to achieve this was to work with
> relative directory paths. It currently looks like:
> 
> <xsl:import href="../../../../../resources/stylesheets/trignm.xsl"/>
> 
> This ofcource makes the system very static and is from my point of view
> a violation against the whole sitemap philosophy. Are there any plans to
> change this or are there any alternative ways to achieve the same
> thing??
> 
> /Thnxs Markus


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: xsl:import question

Posted by Richard in Public <ed...@blueyonder.co.uk>.
Hi Markus

I haven't tried any of this, but it occured to me that you could improve
things somewhat by mounting a 'trig-sub-sitemap', or perhaps even a
library sub-sitemap.

(I cannot remember whether it would be sufficient to do this in your
main sitemap only (i.e. the one in the cocoon root directory) or whether
you would need to mount it in each 'local' sitemap)

Steps would be something like this:

1.  Create directory (e.g. c:/cocoon/lib/trig)
2.  Add to relevant sitemap (try main sitemap first) 

<map:match pattern="cocoon-library/**"> 
  <map:mount uri-prefix="cocoon-library" check-reload="yes"
src="c:/cocoon/lib/sitemap.xmap"/>
</map:match>

3.  Mount each library to the main library sitemap

Another way of putting this is to make the trig stylesheets available as
a separate coocoon site, which all of your projects can draw on.

I know this is a bit of a fuzzy description, but that's how my mind is
right now.  Hope this helps!

Richard



On Thu, 2003-06-12 at 10:08, Markus Alin wrote:
> Hi!!
> 
> I'm using a computational stylesheet with alot of trigonometry templates
> which I include into whatever style sheet which needs it with the
> <xsl:import> tag. I ofcourse want the computational stylesheet to be
> available all over the application and I don't want to keep duplicate
> copies of it. The only way i found to achieve this was to work with
> relative directory paths. It currently looks like:
> 
> <xsl:import href="../../../../../resources/stylesheets/trignm.xsl"/>
> 
> This ofcource makes the system very static and is from my point of view
> a violation against the whole sitemap philosophy. Are there any plans to
> change this or are there any alternative ways to achieve the same
> thing??
> 
> /Thnxs Markus
> 
> 
> 
> ===============================================
> Markus Alin         tel: +41 1 455 70 03
> Swissrisk AG        fax: +41 1 455 70 01
> Räffelstrasse 32    mailto:markus@swissrisk.com
> 8045 Zürich         www.swissrisk.com
> ===============================================
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


xsl:import question

Posted by Markus Alin <ma...@swissrisk.com>.
Hi!!

I'm using a computational stylesheet with alot of trigonometry templates
which I include into whatever style sheet which needs it with the
<xsl:import> tag. I ofcourse want the computational stylesheet to be
available all over the application and I don't want to keep duplicate
copies of it. The only way i found to achieve this was to work with
relative directory paths. It currently looks like:

<xsl:import href="../../../../../resources/stylesheets/trignm.xsl"/>

This ofcource makes the system very static and is from my point of view
a violation against the whole sitemap philosophy. Are there any plans to
change this or are there any alternative ways to achieve the same
thing??

/Thnxs Markus



===============================================
Markus Alin         tel: +41 1 455 70 03
Swissrisk AG        fax: +41 1 455 70 01
Räffelstrasse 32    mailto:markus@swissrisk.com
8045 Zürich         www.swissrisk.com
===============================================



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: can't resolve session in xsp

Posted by morten svanæs <mo...@web-som-virker.no>.
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" <mo...@web-som-virker.no>
To: <co...@xml.apache.org>
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: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org