You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by ma...@home.se on 2000/10/16 12:58:17 UTC

Problem with esql-taglib

Hello,

 I have a problem that I have been working on for a few days now so any
help solving this would be great. I'm running with cocoon-1.8.1-dev
(updated this morning/ unfortunately there is a problem with
turbine-pool.jar that I've posted to cocoon-dev list).

The problem occurs when using the esql and session taglib together.

Here is my XML document (the document is a test page normally there should
be some xslt processing to add the html headers). The msisdn variable is
set in the session on the previous page and is fetched correctly.

-----XML document ----------
<?xml version="1.0"?>

<?cocoon-process type="xsp"?>
<?xml-logicsheet
href="resource://org/apache/cocoon/processor/xsp/library/java/session.xsl"?>
<?xml-logicsheet
href="resource://org/apache/cocoon/processor/xsp/library/sql/esql.xsl"?>

<xsp:page
  language="java"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  xmlns:session="http://www.apache.org/1999/XSP/Session"
  xmlns:esql="http://apache.org/cocoon/SQL/v2"
>

<page>

<html>
<body>

<P><session:get-attribute name="msisdn"/></P>
<P>select * from msisdn2contract where msisdn='<session:get-attribute name="msisdn"/>'</P>

<esql:execute-query inner-method="yes">
<esql:driver>oracle.jdbc.driver.OracleDriver</esql:driver>
<esql:username>sysadm</esql:username>
<esql:password>sysadm</esql:password>
<esql:dburl>processor.xsp.pool.database.default.url=jdbc:oracle:thin:@localhost:1521:ERWIN</esql:dburl>
<esql:query>select customerid from msisdn2contract where msisdn='<session:get-attribute name="msisdn"/>'</esql:query>
<esql:results>
<P><esql:get-string column="customerid"/></P>

</esql:results>
<esql:no-results>
 <error>no results were found here either</error>
</esql:no-results>
<esql:error-results>
 <message><esql:get-message/></message>
 <stacktrace><esql:get-stacktrace/></stacktrace>
</esql:error-results>
</esql:execute-query>


</body>
</html>
</page>

</xsp:page>

----------end xml doc -----------------------

This generates a page that looks like this:

----------- output --------------
<page xmlns:session="http://www.apache.org/1999/XSP/Session">

<html>
<body>

<P>628882101</P>
<P>select * from msisdn2contract where msisdn='628882101'</P>

<error xmlns:session="http://www.apache.org/1999/XSP/Session">no results
were found here either</error>

</body>
</html>
</page>
-----------end output --------------

When checking the java source for this page it looks alright the
interesting section here:

------------- java code ---------------
  _esql_session.query = String.valueOf(""
                        + "select customerid from msisdn2contract where 
msisdn='"
                        + session.getAttribute(
                              String.valueOf("msisdn")
                          )
                        + "'");
                 _esql_session.statement =
_esql_session.connection.createStatement();
                 _esql_session.resultset =
_esql_session.statement.executeQuery(_esql_session.query);
---------------------------------------


Replacing the last get-attribute with a fixed value works perfectly fine
and the query returns the correct information.

Does the esql-block create its own session somehow and we lose the session
information???

TIA

Magnus Egnerfors

-- 
Magnus Egnerfors	
Email: magnus.egnerfors@home.se



Re: Problem with esql-taglib

Posted by Donald Ball <ba...@webslingerZ.com>.
On Tue, 17 Oct 2000 magnus.egnerfors@home.se wrote:

> 
> Continuing in the quest for finding the problem or at least a work around
> I tried to forward the values via the request object but ran into another
> problem that seems to be strange.

oh, duh. i think you need to do this

<xsp:expr><session:get-attribute name="msisdn"/>.toString()</xsp:expr>

- donald


Re: Problem with esql-taglib

Posted by ma...@home.se.
Continuing in the quest for finding the problem or at least a work around
I tried to forward the values via the request object but ran into another
problem that seems to be strange.


---------- XML File ------------------------

<?xml version="1.0"?>

<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="display-display.xsl" type="text/xsl"?>

<xsp:page
  language="java"
  xmlns:esql="http://apache.org/cocoon/SQL/v2"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  xmlns:request="http://www.apache.org/1999/XSP/Request"
  xmlns:session="http://www.apache.org/1999/XSP/Session"
>


<PAGE>
 <LINK><xsp:attribute 
name="linkname">contract-list.xml?msisdn=<session:get-attribute
name='msisdn'/></xsp:attribute><session:get-attribute 
name='msisdn'/></LINK>

</PAGE>

</xsp:page>

------- end  XML File -----------------------

------- XSL file ----------------------------

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <xsl:template match="page">
    <xsl:processing-instruction name="cocoon-format">type="text/html"</xsl:processing-instruction>
    <html>
      <body>
        <xsl:apply-templates select="LINK"/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="LINK">
    <A><xsl:attribute name="HREF"><xsl:value-of select="./@linkname"/></xsl:attribute><xsl:value-of select="."/></A>
  </xsl:template>

</xsl:stylesheet>

---------- end xsl file -------------------

The generated output looks like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<A href="contract-list.xml?msisdn=[Ljava.lang.String;@52ad0b74">628882101</A>

Is there an error that I have made in my code or why do I get the value
[Ljava.lang.String;@52ad0b74 in the link?

I'm using 1.8.1-dev from CVS checkout this morning.


/Magnus





Re: Problem with esql-taglib

Posted by ma...@home.se.

> On Tue, 17 Oct 2000 magnus.egnerfors@home.se wrote:
> 
> > It doesn't make any difference it still generates the no-results
> > caluse. The query looks like this with the change:
> > 
> > <esql:query>select customerid from msisdn2contract where
> > msisdn='<xsp:expr>session.getValue("msisdn").toString()</xsp:expr>'</esql:query>
> 
> what is the type of the object keyed by the msisdn string? what do you get
> if you just spit it out:
> 
> <junk><xsp:expr>session.getValue("msisdn").toString()</xsp:expr></junk>?
> 
> what's the generated source code look like now?
> 
> - donald

Including this into the document generates the following entry in the
generated page:

<junk>[Ljava.lang.String;@75b84b72</junk>

The code looks like this:

    xspCurrentNode =
      document.createElement("junk");
    xspParentNode.appendChild(xspCurrentNode);

    
        xspCurrentNode.appendChild(
          xspExpr(session.getValue("msisdn").toString(), document)
        );
      

    ((Element) xspCurrentNode).normalize();
    xspCurrentNode = (Node) xspNodeStack.pop();

Was this what you wanted to see?

/Magnus



Re: Problem with esql-taglib

Posted by Donald Ball <ba...@webslingerZ.com>.
On Tue, 17 Oct 2000 magnus.egnerfors@home.se wrote:

> It doesn't make any difference it still generates the no-results
> caluse. The query looks like this with the change:
> 
> <esql:query>select customerid from msisdn2contract where
> msisdn='<xsp:expr>session.getValue("msisdn").toString()</xsp:expr>'</esql:query>

what is the type of the object keyed by the msisdn string? what do you get
if you just spit it out:

<junk><xsp:expr>session.getValue("msisdn").toString()</xsp:expr></junk>?

what's the generated source code look like now?

- donald


Re: Problem with esql-taglib

Posted by ma...@home.se.
> hmm. what if you use
> 
> <xsp:expr>session.getValue("msisdn").toString()</xsp:expr>
> 
> instead of
> 
> <session:get-attribute name="msisdn"/>
> 
> (or whatever it is)?
> 
> - donald

It doesn't make any difference it still generates the no-results
caluse. The query looks like this with the change:

<esql:query>select customerid from msisdn2contract where
msisdn='<xsp:expr>session.getValue("msisdn").toString()</xsp:expr>'</esql:query>

If I make a change in calling the page and pass the parameter as a request
parameter http://file?msisdn=628882101 and fetch it through the request
object it works.

<esql:query>select customerid from msisdn2contract where
msisdn=<xsp:expr>request.getParameterValues("msisdn")[0]</xsp:expr></esql:query>

This way I can get around the problem but I would prefer to find a
solution to this problem. 

/Magnus


Re: Problem with esql-taglib

Posted by Donald Ball <ba...@webslingerZ.com>.
On Tue, 17 Oct 2000 magnus.egnerfors@home.se wrote:

> I've have tested this with Java 2 SDK 1.3 Bete refresh for Linux and IBM
> SDK 1.3-1.1 and no luck with either.
> 
> Any clues what might be wrong? 

hmm. what if you use

<xsp:expr>session.getValue("msisdn").toString()</xsp:expr>

instead of

<session:get-attribute name="msisdn"/>

(or whatever it is)?

- donald


Re: Problem with esql-taglib

Posted by ma...@home.se.
> On Mon, 16 Oct 2000 magnus.egnerfors@home.se wrote:
> 
> >  I have a problem that I have been working on for a few days now so any
> > help solving this would be great. I'm running with cocoon-1.8.1-dev
> > (updated this morning/ unfortunately there is a problem with
> > turbine-pool.jar that I've posted to cocoon-dev list).
> 
> hope this is fixed now...
Yes.

> 
> > Here is my XML document (the document is a test page normally there should
> > be some xslt processing to add the html headers). The msisdn variable is
> > set in the session on the previous page and is fetched correctly.
> > 
> > -----XML document ----------
> > <?xml version="1.0"?>
> > 
> > <?cocoon-process type="xsp"?>
> > <?xml-logicsheet
> > href="resource://org/apache/cocoon/processor/xsp/library/java/session.xsl"?>
> > <?xml-logicsheet
> > href="resource://org/apache/cocoon/processor/xsp/library/sql/esql.xsl"?>
> > 
> > <xsp:page
> >   language="java"
> >   xmlns:xsp="http://www.apache.org/1999/XSP/Core"
> >   xmlns:session="http://www.apache.org/1999/XSP/Session"
> >   xmlns:esql="http://apache.org/cocoon/SQL/v2"
> > >
> > 
> > <page>
> > 
> > <html>
> > <body>
> > 
> > <P><session:get-attribute name="msisdn"/></P>
> > <P>select * from msisdn2contract where msisdn='<session:get-attribute name="msisdn"/>'</P>
> > 
> > <esql:execute-query inner-method="yes">
> > <esql:driver>oracle.jdbc.driver.OracleDriver</esql:driver>
> > <esql:username>sysadm</esql:username>
> > <esql:password>sysadm</esql:password>
> > <esql:dburl>processor.xsp.pool.database.default.url=jdbc:oracle:thin:@localhost:1521:ERWIN</esql:dburl>
> > <esql:query>select customerid from msisdn2contract where msisdn='<session:get-attribute name="msisdn"/>'</esql:query>
> > <esql:results>
> > <P><esql:get-string column="customerid"/></P>
> > 
> > </esql:results>
> > <esql:no-results>
> >  <error>no results were found here either</error>
> > </esql:no-results>
> > <esql:error-results>
> >  <message><esql:get-message/></message>
> >  <stacktrace><esql:get-stacktrace/></stacktrace>
> > </esql:error-results>
> > </esql:execute-query>
> > 
> > 
> > </body>
> > </html>
> > </page>
> > 
> > </xsp:page>
> > 
> > ----------end xml doc -----------------------
> > 
> > This generates a page that looks like this:
> > 
> > ----------- output --------------
> > <page xmlns:session="http://www.apache.org/1999/XSP/Session">
> > 
> > <html>
> > <body>
> > 
> > <P>628882101</P>
> > <P>select * from msisdn2contract where msisdn='628882101'</P>
> > 
> > <error xmlns:session="http://www.apache.org/1999/XSP/Session">no results
> > were found here either</error>
> > 
> > </body>
> > </html>
> > </page>
> 
> that all looks fine. the query runs, the variable is retrieved from the
> session. what gives? 	

The previewed query shown above returns a correct result when running it
through sqlplus or any other tool for accessing the db.

[ ... snip removed java code ...]

> > 
> > Replacing the last get-attribute with a fixed value works perfectly fine
> > and the query returns the correct information.
> 
> so what, replacing String.valueOf("msisdn") with "msisdn" makes everything
> work? that's completely whacked - that strongly indicates a jvm
> error. i assert that String.valueOf("msisdn").equals("msisdn"). am i
> misunderstanding something?

What happens is if I replace the query that looks like this:

<esql:query>select customerid from msisdn2contract where
msisdn='<session:get-attribute name="msisdn"/>'</esql:query>

with 

<esql:query>select customerid from msisdn2contract where
msisdn='628882101'</esql:query>

the the query works as the result set is returned correctly.

I've have tested this with Java 2 SDK 1.3 Bete refresh for Linux and IBM
SDK 1.3-1.1 and no luck with either.

Any clues what might be wrong? 
How can I do some debugging to check/print the values in the generated
java code thats located in the repository. Just modify the source code and
access the page?

> 
> > Does the esql-block create its own session somehow and we lose the session
> > information???
> 
> nope. esql knows nothing whatsoever about sessions. it relies on
> xsl:apply-templates to invoke actions from other logicsheets.

I've noticed that in my testing. The session-id is the same in all parts
of the query.

/Magnus



Re: Problem with esql-taglib

Posted by Donald Ball <ba...@webslingerZ.com>.
On Mon, 16 Oct 2000 magnus.egnerfors@home.se wrote:

>  I have a problem that I have been working on for a few days now so any
> help solving this would be great. I'm running with cocoon-1.8.1-dev
> (updated this morning/ unfortunately there is a problem with
> turbine-pool.jar that I've posted to cocoon-dev list).

hope this is fixed now...

> Here is my XML document (the document is a test page normally there should
> be some xslt processing to add the html headers). The msisdn variable is
> set in the session on the previous page and is fetched correctly.
> 
> -----XML document ----------
> <?xml version="1.0"?>
> 
> <?cocoon-process type="xsp"?>
> <?xml-logicsheet
> href="resource://org/apache/cocoon/processor/xsp/library/java/session.xsl"?>
> <?xml-logicsheet
> href="resource://org/apache/cocoon/processor/xsp/library/sql/esql.xsl"?>
> 
> <xsp:page
>   language="java"
>   xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>   xmlns:session="http://www.apache.org/1999/XSP/Session"
>   xmlns:esql="http://apache.org/cocoon/SQL/v2"
> >
> 
> <page>
> 
> <html>
> <body>
> 
> <P><session:get-attribute name="msisdn"/></P>
> <P>select * from msisdn2contract where msisdn='<session:get-attribute name="msisdn"/>'</P>
> 
> <esql:execute-query inner-method="yes">
> <esql:driver>oracle.jdbc.driver.OracleDriver</esql:driver>
> <esql:username>sysadm</esql:username>
> <esql:password>sysadm</esql:password>
> <esql:dburl>processor.xsp.pool.database.default.url=jdbc:oracle:thin:@localhost:1521:ERWIN</esql:dburl>
> <esql:query>select customerid from msisdn2contract where msisdn='<session:get-attribute name="msisdn"/>'</esql:query>
> <esql:results>
> <P><esql:get-string column="customerid"/></P>
> 
> </esql:results>
> <esql:no-results>
>  <error>no results were found here either</error>
> </esql:no-results>
> <esql:error-results>
>  <message><esql:get-message/></message>
>  <stacktrace><esql:get-stacktrace/></stacktrace>
> </esql:error-results>
> </esql:execute-query>
> 
> 
> </body>
> </html>
> </page>
> 
> </xsp:page>
> 
> ----------end xml doc -----------------------
> 
> This generates a page that looks like this:
> 
> ----------- output --------------
> <page xmlns:session="http://www.apache.org/1999/XSP/Session">
> 
> <html>
> <body>
> 
> <P>628882101</P>
> <P>select * from msisdn2contract where msisdn='628882101'</P>
> 
> <error xmlns:session="http://www.apache.org/1999/XSP/Session">no results
> were found here either</error>
> 
> </body>
> </html>
> </page>

that all looks fine. the query runs, the variable is retrieved from the
session. what gives?

> When checking the java source for this page it looks alright the
> interesting section here:
> 
> ------------- java code ---------------
>   _esql_session.query = String.valueOf(""
>                         + "select customerid from msisdn2contract where 
> msisdn='"
>                         + session.getAttribute(
>                               String.valueOf("msisdn")
>                           )
>                         + "'");
>                  _esql_session.statement =
> _esql_session.connection.createStatement();
>                  _esql_session.resultset =
> _esql_session.statement.executeQuery(_esql_session.query);
> ---------------------------------------
> 
> 
> Replacing the last get-attribute with a fixed value works perfectly fine
> and the query returns the correct information.

so what, replacing String.valueOf("msisdn") with "msisdn" makes everything
work? that's completely whacked - that strongly indicates a jvm
error. i assert that String.valueOf("msisdn").equals("msisdn"). am i
misunderstanding something?

> Does the esql-block create its own session somehow and we lose the session
> information???

nope. esql knows nothing whatsoever about sessions. it relies on
xsl:apply-templates to invoke actions from other logicsheets.

- donald