You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by vupt <vu...@yahoo.com> on 2000/03/01 21:10:30 UTC
Problem using xsp: "Undefined variable or class name: request"
Hi,
I am having a problem generating an XSP page. I would
like to have a function that
returns a string based on a request parameter. If
anyone can point out my error,
I would be very grateful.
When I run my example, I obtain this error:
java.lang.Exception: XSP Java Compiler: Compilation
failed for _clean_page.java
25: Undefined variable or class name: request
String
vals[]=request.getParameterValues(name);
^
1 error
at
org.apache.cocoon.processor.xsp.language.java.XSPJavaProcessor.compile(Compiled
Code)
at org.apache.cocoon.Cocoon.service(Cocoon.java:145)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at
org.apache.jserv.JServConnection.processRequest(JServConnection.java:314)
at
org.apache.jserv.JServConnection.run(JServConnection.java:188)
at java.lang.Thread.run(Thread.java:479)
Here is the file that causes the error.
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="page">
<xsl:processing-instruction
name="cocoon-process">type="xsp"</xsl:processing-instruction>
<xsl:processing-instruction
name="cocoon-process">type="xslt"</xsl:processing-instruction>
<xsl:processing-instruction
name="xml-stylesheet">href="page-html.xsl"
type="text/xsl"</xsl:processing-instruction>
<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core">
<xsp:logic><![CDATA[
private String getValue(String name, String
value) {
String
vals[]=request.getParameterValues(name);
if (vals == null) return value;
else return vals[0];
}
]]></xsp:logic>
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsp:page>
</xsl:template>
<xsl:template match="title">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="parameters">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="parameter">
<xsl:copy>
<xsl:attribute name="name">os</xsl:attribute>
<xsp:attribute
name="value"><xsp:expr>getValue("<xsl:value-of
select="@name"/>", "<xsl:value-of
select="@value"/>")</xsp:expr></xsp:attribute>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com