cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Heidl <he...@zib.de>
Subject Re: Class creation
Date Thu, 28 Sep 2000 12:12:05 GMT
Peter Verhage wrote:
> 
> I've got a xsp page, and inside <xsp:logic></xsp:logic> tags I have
> created a simple class. But this doesn't work because the class get's
> compiled within another class:
> 
>     ....
>     public class _index extends XSPPage {
>       /* User Class Declarations */
> 
>       public class Counter
>       {
>         private int count;
> 
>         public int Value()
>         {
>           return count;
>         }
> 
>         public void Raise()
>         {
>           count += 1;
>         }
> 
>         public void Reset()
>         {
>           count = 0;
>         }
>       };
>       ....
> 
> My real code is something like this:
>     ....
>     ....
>     <xsp:logic>
>       public class Counter
>       {
>         private int count;
> 
>         public int Value()
>         {
>           return count;
>         }
> 
>         public void Raise()
>         {
>           count += 1;
>         }
> 
>         public void Reset()
>         {
>           count = 0;
>         }
>       };
>     </xsp:logic>
> 
>     <xsl:apply-templates/>
>   </xsp:page>
>    ....
>    ....
> 
> I'm probably doing something very very wrong :). But how do I create my
> own class? And where do I have to put it?

Inner classes are allowed in Java so basically this shouldn't
be a problem. But maybe that's not what you intended to do.

If you want your classes external (and this is the usual 
case I think) put them in one or more packages (directories),
make a jar and let the servlet-engine know of it (put the jar 
in it's classpath).
Then you can include them inside the xsp with the
<xsp:include> statement.

hope this helps,
Sebastian

Mime
View raw message