You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by gu...@teleco.upv.es on 2000/03/13 15:31:00 UTC

Beginer XSP question

Hi,

I have the following XSP page:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet  href="frames2.xsl" type="text/xsl"?>


<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core">
       
       <xsp:logic>
          
           HttpSession session=request.getSession(true);
           String done=(String)session.getValue("file");          
             
        </xsp:logic>
        <session><xsp:expr>done</xsp:expr></session>
    
  
</xsp:page>


When i call the page i get this error.
java.lang.Exception: XSP Java Compiler: Compilation failed for
_frames.java
25: Undefined variable or class name: request
           HttpSession session=request.getSession(true);
                               

I know that probably is a stupid question but i feel losed and i do not
know whwt i am doing wrong. 

Thanks in advance.

Re: Beginer XSP question

Posted by Mike Engelhart <me...@earthtrip.com>.
guiferpo@teleco.upv.es wrote:

> 
> I have the following XSP page:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet  href="frames2.xsl" type="text/xsl"?>
> 
> 
> <xsp:page language="java"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core">
> 
> <xsp:logic>
> 
> HttpSession session=request.getSession(true);
> String done=(String)session.getValue("file");
> 
> </xsp:logic>
> <session><xsp:expr>done</xsp:expr></session>
> 
> 
> </xsp:page>
> 
> 
> When i call the page i get this error.
> java.lang.Exception: XSP Java Compiler: Compilation failed for
> _frames.java
> 25: Undefined variable or class name: request
> HttpSession session=request.getSession(true);
<xsp:logic> elements that appear outside of the root XSP node (your example
doesn't have an xsp root node) are class variables outside the scope of the
request and session objects.  You need to do something like this:

<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core">
       
    <document>
       <xsp:logic>
          
           HttpSession session=request.getSession(true);
           String done=(String)session.getValue("file");
             
        </xsp:logic>
        <session><xsp:expr>done</xsp:expr></session>
    </document >
  
</xsp:page>


This will work. 

Mike


Re: Beginer XSP question

Posted by Sebastian Hauer <ha...@uni-freiburg.de>.
Hi,

I had the same error some time ago.

you will have to place your <xsp:logic> block into one of your xml tags:

Like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet  href="frames2.xsl" type="text/xsl"?>
 
<xsp:page language="java"
 xmlns:xsp="http://www.apache.org/1999/XSP/Core">
       <session>
         <xsp:logic>
           
            HttpSession session=request.getSession(true);
            String done=(String)session.getValue("file");          
              
         </xsp:logic>
	 <xsp:expr>done</xsp:expr>
       </session>
</xsp:page>

> 25: Undefined variable or class name: request
>            HttpSession session=request.getSession(true);

ciao,

	Sebastian