cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: importing own classes inside XSP's
Date Wed, 24 Jan 2001 13:43:00 GMT
Roberto Viana wrote:
> 
> Hi there,
> 
> Im trying to do an import inside a XSP page using the <xsp:structure> tag,
> the classes are inside a *.jar that I previously specified in the classpath
> of my servlet engine (JRun3.0).
> 
> This is how the import is done in the xsp:

Try moving the xsp:structure section directly beneath the
xsp:page element--like this:

<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
  <xsp:structure>
    <xsp:include>com.bin.dia.testsbean1.TestBean1</xsp:include>
  </xsp:structure>
  <page title="TEST">
    <!-- .... insert the rest here -->
  </page>
</xsp:page>

I will warn you about another gotcha that you are going to face
after you do this.  You have to use the <util:include-string>
element if you want to convert a string to valid XML.  Otherwise,
you will get "&gt;test&lt;Test Element&gt;/test&lt;" instead of
"<test>Test Element</test>"

> 
> <?xml version="1.0"?>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="sample2.xsl" type="text/xsl"?>
> 
> <xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
>   <page title="TEST">
>    <xsp:structure>
>         <xsp:include>com.bon.dia.testsbean1.TestBean1</xsp:include>
>    </xsp:structure>
>     <xsp:logic>
>         TestBean1 testBean = new TestBean1();
>         String sourceXML = testBean.doXML();
>     </xsp:logic>
> 
>     <p>
>       This is the output:
>       <xsp:expr>sourceXML</xsp:expr>
>     </p>
>   </page>
> </xsp:page>
> 
> When I call the page I get these errors:
> 
> ************************************************
> 
> java.lang.Exception: XSP Java Compiler: Compilation failed for _sample2.java
> 93: Undefined variable, class, or package name: com
> 
>     com.bon.dia.testsbean1.TestBean1
> 
>     ^
> 
> 107: Class
> _C_._tomcat3_2._jakarta_tomcat_3_2._webapps._cocoon._servlets._samplexsp.Tes
> tBean1 not found.
> 
>         TestBean1 testBean = new TestBean1();
> 
>         ^
> 
> 107: Class
> _C_._tomcat3_2._jakarta_tomcat_3_2._webapps._cocoon._servlets._samplexsp.Tes
> tBean1 not found.
> 
>         TestBean1 testBean = new TestBean1();
> 
>                                  ^
> 
> 3 errors
> ***********************************************
> 
> Im using Jrun 3.0 and Cocoon 1.8.0
> 
> Any ideas what can be wrong?
> 
> Roberto.
> 
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> 
> 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