cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <ba...@webslingerZ.com>
Subject Re: Problem using xsp: "Undefined variable or class name: request"
Date Thu, 02 Mar 2000 01:37:47 GMT
Why don't you use the request namespace taglib?

- donald

On Wed, 1 Mar 2000, vupt wrote:

> Hi,
> 
> I was able to find a workaround for my problem.
> Instead of accessing the request object directly in
> the function, I passed the parameterValues array
> String that I needed to the function instead.
> 
> Here is an updated working stylesheet:
> <?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[
>        HashMap parameters=new HashMap();
> 
>         private String getValue(String value, String
> [] vals) {
>           String parameterValue;
>           if (vals == null){
>             parameterValue= value;
>           }else{
>             parameterValue= vals[0];
>           }
>           return parameterValue;
>         }
> 
>         private String addParameter(String name,
> String value, HashMap parameters) {
>           parameters.put(name, value);
>           return "";
>           
>         }
> 
>          private String getParameter(String
> name,HashMap parameters) {
>           return (String) parameters.get(name);
>          
>           
>         }
>     ]]></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="@value"/>",
> request.getParameterValues("<xsl:value-of
> select="@name"/>"))</xsp:expr></xsp:attribute> 
>      <xsp:expr>addParameter("<xsl:value-of
> select="@name"/>",getValue("<xsl:value-of
> select="@value"/>",
> request.getParameterValues("<xsl:value-of
> select="@name"/>")),parameters)</xsp:expr>
>     
>     </xsl:copy>
>   </xsl:template>
>  
> </xsl:stylesheet>
> 
> --- vupt <vupt@yahoo.com> wrote:
> > 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
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail:
> > cocoon-users-help@xml.apache.org
> > 
> > 
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 


Mime
View raw message