You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Reuben Christie <rc...@decisiontech.com> on 2003/10/27 15:15:36 UTC

xsp calling function

hi all, I am really stuck with XSP calling a function of a java class. here
is my problem.
This is the xsp code,

<?xml version="1.0"?>
<xsp:page xmlns:xsp="http://apache.org/xsp">
   <xsp:logic>PACK.Test t=new PACK.Test();
String st=t.other();
</xsp:logic>
<greeting><xsp:expr>st</xsp:expr></greeting>
</xsp:page>

and this is the Test.java code.

import com.decisiontech.framework.test.*;

public class Test {

    public Test() {
    }

    public String other() {
       System.out.println("helloworld");
       return hello;
       }
    }
now the problem is this, xsp calls this fucntion two times, i dont know
why..but i checked the stdout.log file under tomcat log directory and it
prints helloworld two times. and there for i m stuck here. the abouve is the
example so it returns back hello but in my actual code the situation is
different and therefor i m not been able to return the correct value.
please somebody help me out with this.

thanks alot in advance
reuben


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: xsp calling function

Posted by Justin Fagnani-Bell <ju...@paraliansoftware.com>.
Reuben,

I can't think of why this XSP would be calling other() twice, but maybe  
I can give you pointers on tracking down the problem.

First your <xsp:logic> section is outside of the root element for your  
XML, the <greeting> element. This will be inserted as class level code  
by the XSP logicsheet, it won't be placed inside the generate() method.  
You may already know this, but I thought I'd point it out since the  
code there doesn't look like it needs to be class-level. (I personally  
think this is a confusing part of XSP and that class level code should  
be placed in an element called <xsp:class-logic> or something).

The easy and direct way to figure out what's going on is to look at the  
generated source code. It's usually someplace like  
TOMCAT_HOME/work/Standalone/localhost/_/cocoon-files/org/apache/cocoon/ 
www/

My only guess as to why this might actually be happening is that  
somehow the code in your <xsp:logic> element is being placed at the  
class level, _and_ inside generate(). Looking at the source shoud tell  
you what's up though.

-Justin

On Monday, October 27, 2003, at 06:15  AM, Reuben Christie wrote:

> hi all, I am really stuck with XSP calling a function of a java class.  
> here
> is my problem.
> This is the xsp code,
>
> <?xml version="1.0"?>
> <xsp:page xmlns:xsp="http://apache.org/xsp">
>    <xsp:logic>PACK.Test t=new PACK.Test();
> String st=t.other();
> </xsp:logic>
> <greeting><xsp:expr>st</xsp:expr></greeting>
> </xsp:page>
>
> and this is the Test.java code.
>
> import com.decisiontech.framework.test.*;
>
> public class Test {
>
>     public Test() {
>     }
>
>     public String other() {
>        System.out.println("helloworld");
>        return hello;
>        }
>     }
> now the problem is this, xsp calls this fucntion two times, i dont know
> why..but i checked the stdout.log file under tomcat log directory and  
> it
> prints helloworld two times. and there for i m stuck here. the abouve  
> is the
> example so it returns back hello but in my actual code the situation is
> different and therefor i m not been able to return the correct value.
> please somebody help me out with this.
>
> thanks alot in advance
> reuben
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org