You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Brett McLaughlin <br...@earthlink.net> on 2000/03/24 19:05:27 UTC
Help on request variable in XSP
Is there something particular that has to be done to get access to the
request variable in XSP?
In this XSP page:
<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="XSL/JavaXML.fo.xsl" type="text/xsl"?>
<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>
<xsp:logic>
private boolean isAuthor() {
String role = request.getParameterValues("userRole")[0];
is (role.equals("author")) {
return true;
} else {
return false;
}
}
</xsp:logic>
<root>
<!-- some content -->
</root>
</xsp:page>
It gives me the following error every time:
java.lang.Exception: XSP Java Compiler: Compilation failed for
_chapterOne.java
25: Undefined variable or class name: request
String role = request.getParameterValues("userRole")[0];
1 error
.... (stack trace ending at XSPJavaProcessor)
any ideas, please?
Thanks,
Brett
-----
Brett McLaughlin
Metro Information Systems
Work: (972) 724-3161
Mobile: (817) 825-7187
Re: Help on request variable in XSP
Posted by Mike Engelhart <me...@earthtrip.com>.
<?xml version="1.0"?>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="xslt"?>
>
> <?xml-stylesheet href="XSL/JavaXML.fo.xsl" type="text/xsl"?>
>
> <xsp:page language="java"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>>
>
> <xsp:logic>
> private boolean isAuthor() {
> String role = request.getParameterValues("userRole")[0];
>
> is (role.equals("author")) {
> return true;
> } else {
> return false;
> }
> }
> </xsp:logic>
>
> <root>
> <!-- some content -->
> </root>
> </xsp:page>
<xsp:logic> tags outside of the xml root element (in your case <root>) are
class variables. since the request object is passed into the xsp page, you
need to access it from within the root element which is processed inside a
method call (populateDocument()? - i forget off the top of my head - it's in
the source though)
Anyway, that is why you're getting that error. If you put
request.getParameter("MYPARAM") inside your <root> element it will play
nice..
Mike Engelhart