You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Nadine Carlton <na...@hp.com> on 2000/08/18 00:27:33 UTC

Parameter passing with cocoon

Hi,

  I'm running Cocoon 1.7.3 and have it successfully accessing an
Oracle database thanks to help from this group.

  I have a different question though.  I need to pass parameters
to the Cocoon servers.  The parameters may come from a browser
client in a client/server environment, but they may also be passed
through an application server in a three tier environment.  From the
Cocoon XSP documentation and a sample in Brett McLaughlin's
Java and XML book, I'm trying to debug a two tier sample.  It 
currently won't parse and I've included the XSP file and the parser
error below.  Does anyone see what is wrong with the code?  Is there
an option to get more information about where the parsing is failing?

  Also, how should I design the 3-tier, client/application server/backend DB server
code?  For example, should parameters between the app server (written in Java)
and DB server (written with Cocoon) be sent in an XML document or
similar to the two tier parameter solution?  Does anyone have pointers
to sample code for this?

Nadine Carlton
HP

<?xml version="1.0" ?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="sql"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="sorttest.xsl" type="text/xsl"?>
<xsp:logic>
<![CDATA[
     String[] dbuserparmValues = request.getParameterValues("user");
     String[] dbpasswordparmValues = request.getParameterValues("password");
     String[] customerparmValues = request.getParameterValues("customer");
     String[] propertiesparmValues = request.getParameterValues("properties");

     if (dbuserparmValues != null) {
         String dbuserparm = dbuserparmValues[0];
     } else{
         String dbuserparm = "scott";
     }
     if (dbpasswordparmValues != null) {
         String dbpasswordparm = dbpasswordparmValues[0];
     } else{
         String dbpasswordparm = "tiger";
     }
     if (customerparmValues != null) {
         String querystring = "select * from emp where ENAME like 'customerparmValues[0]%';
     } else{
         String querystring = "select * from emp";
     }

]]>
     
</xsp:logic>
 
<xsp:page
  language="java"
  xmlns:sql="http://www.apache.org/1999/SQL"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core">
  
  <page title="SQL Search Results">
  <sql:execute-query>
  <sql:driver>oracle.jdbc.driver.OracleDriver</sql:driver>
  <sql:dburl>jdbc:oracle:thin:@nc703572:1521:orant815</sql:dburl>
     <sql:username>dbuserparm</sql:username>
     <sql:password>dbpasswordparm</sql:password>
  <sql:tag-case>lower</sql:tag-case>
  <sql:null-indicator>yes</sql:null-indicator>
  <sql:doc-element>ROWSET</sql:doc-element>
  <sql:row-element>ROW</sql:row-element>
  <sql:id-attribute-column>none</sql:id-attribute-column>
  <sql:query>querystring</sql:query>
  <sql:count-attribute>nome</sql:count-attribute>
  </sql:execute-query>
  </page>
</xsp:page>
 
The parser error in the browser:
<html> <head>  <meta name="GENERATOR" content="Cocoon 1.7.3"> </head> <body> <p><br></p> <center>  <table border="0" width="80%" bgcolor="#000000" cellspacing="0" cellpadding="0">  <tr>   <td width="100%"><table border="0" width="100%" cellpadding="4">    <tr>     <td width="100%" bgcolor="#c0c0c0"><p align="right"><font color="red"><big><big>Cocoon 1.7.3</big></big></font></td>    </tr>    <tr>      <td width="100%" bgcolor="#f0f0f0">       <p align="center"><br></p>
<h3 align="center">Error found handling the request.</h3>
<blockquote><pre>org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed.
 at org.apache.cocoon.parser.AbstractParser.fatalError(AbstractParser.java:105)
 at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1347)
 at org.apache.xerces.framework.XMLDocumentScanner$TrailingMiscDispatcher.dispatch(XMLDocumentScanner.java, Compiled Code)
 at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java, Compiled Code)
 at org.apache.xerces.framework.XMLParser.parse(XMLParser.java, Compiled Code)
 at org.apache.cocoon.parser.XercesParser.parse(XercesParser.java:83)
 at org.apache.cocoon.parser.AbstractParser.parse(AbstractParser.java:83)
 at org.apache.cocoon.producer.ProducerFromFile.getDocument(ProducerFromFile.java:78)
 at org.apache.cocoon.Engine.handle(Engine.java, Compiled Code)
 at org.apache.cocoon.Cocoon.service(Cocoon.java:166)
 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)
</pre></blockquote>
      </td>     </tr>     <tr>      <td width="100%" bgcolor="#FFFFFF">       <strong>Warning</strong>: this page has been dynamically generated.      </td>     </tr>    </table>   </td>  </tr> </table> </center> <p align="center">   <font size="-1">   Copyright (c) 1999-2000 <a href="http://xml.apache.org">The Apache XML Project</a>.<br>   All rights reserved.   </font> </p> </body> </html>


Re: Parameter passing with cocoon

Posted by Ricardo Rocha <ri...@apache.org>.
> Nadine Carlton wrote:
> 
> Hi,
> 
>   I'm running Cocoon 1.7.3 and have it successfully accessing an
> Oracle database thanks to help from this group.
> 
>   I have a different question though.  I need to pass parameters
> to the Cocoon servers.  The parameters may come from a browser
> client in a client/server environment, but they may also be passed
> through an application server in a three tier environment.  From the
> Cocoon XSP documentation and a sample in Brett McLaughlin's
> Java and XML book, I'm trying to debug a two tier sample.  It
> currently won't parse and I've included the XSP file and the parser
> error below.  Does anyone see what is wrong with the code?  Is there
> an option to get more information about where the parsing is failing?

The problem with the code below is that your <xsp:logic> block
_must_ be placed below the <page> element.

This is not an XSP restriction, but an XML constraint: an XML
document must have one and only one root element. The XSP page
in question has 2 top-level elements: <xsp:logic> and <xsp:page>.

> <?xml version="1.0" ?>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="sql"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="sorttest.xsl" type="text/xsl"?>
> <xsp:logic>
> <![CDATA[
>      String[] dbuserparmValues = request.getParameterValues("user");
>      String[] dbpasswordparmValues =
> request.getParameterValues("password");
>      String[] customerparmValues =
> request.getParameterValues("customer");
>      String[] propertiesparmValues =
> request.getParameterValues("properties");
> 
>      if (dbuserparmValues != null) {
>          String dbuserparm = dbuserparmValues[0];
>      } else{
>          String dbuserparm = "scott";
>      }
>      if (dbpasswordparmValues != null) {
>          String dbpasswordparm = dbpasswordparmValues[0];
>      } else{
>          String dbpasswordparm = "tiger";
>      }
>      if (customerparmValues != null) {
>          String querystring = "select * from emp where ENAME like
> 'customerparmValues[0]%';
>      } else{
>          String querystring = "select * from emp";
>      }
> 
> ]]>
> 
> </xsp:logic>
> 
> <xsp:page
>   language="java"
>   xmlns:sql="http://www.apache.org/1999/SQL"
>   xmlns:xsp="http://www.apache.org/1999/XSP/Core">
> 
>   <page title="SQL Search Results">
>   <sql:execute-query>
>   <sql:driver>oracle.jdbc.driver.OracleDriver</sql:driver>
>   <sql:dburl>jdbc:oracle:thin:@nc703572:1521:orant815</sql:dburl>
>      <sql:username>dbuserparm</sql:username>
>      <sql:password>dbpasswordparm</sql:password>
>   <sql:tag-case>lower</sql:tag-case>
>   <sql:null-indicator>yes</sql:null-indicator>
>   <sql:doc-element>ROWSET</sql:doc-element>
>   <sql:row-element>ROW</sql:row-element>
>   <sql:id-attribute-column>none</sql:id-attribute-column>
>   <sql:query>querystring</sql:query>
>   <sql:count-attribute>nome</sql:count-attribute>
>   </sql:execute-query>
>   </page>
> </xsp:page>
> 
> The parser error in the browser:
> <html> <head>  <meta name="GENERATOR" content="Cocoon 1.7.3"> </head>
> <body> <p><br></p> <center>  <table border="0" width="80%"
> bgcolor="#000000" cellspacing="0" cellpadding="0">  <tr>   <td
> width="100%"><table border="0" width="100%" cellpadding="4">
> <tr>     <td width="100%" bgcolor="#c0c0c0"><p align="right"><font
> color="red"><big><big>Cocoon 1.7.3</big></big></font></td>    </tr>
> <tr>      <td width="100%" bgcolor="#f0f0f0">       <p
> align="center"><br></p>
> <h3 align="center">Error found handling the request.</h3>
> <blockquote><pre>org.xml.sax.SAXParseException: The markup in the
> document following the root element must be well-formed.
>  at
> org.apache.cocoon.parser.AbstractParser.fatalError(AbstractParser.java:105)
>  at
> org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1347)
>  at
> org.apache.xerces.framework.XMLDocumentScanner$TrailingMiscDispatcher.dispatch(XMLDocumentScanner.java,
> Compiled Code)
>  at
> org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java,
> Compiled Code)
>  at org.apache.xerces.framework.XMLParser.parse(XMLParser.java,
> Compiled Code)
>  at org.apache.cocoon.parser.XercesParser.parse(XercesParser.java:83)
>  at
> org.apache.cocoon.parser.AbstractParser.parse(AbstractParser.java:83)
>  at
> org.apache.cocoon.producer.ProducerFromFile.getDocument(ProducerFromFile.java:78)
>  at org.apache.cocoon.Engine.handle(Engine.java, Compiled Code)
>  at org.apache.cocoon.Cocoon.service(Cocoon.java:166)
>  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)
> </pre></blockquote>
>       </td>     </tr>     <tr>      <td width="100%"
> bgcolor="#FFFFFF">       <strong>Warning</strong>: this page has been
> dynamically generated.      </td>     </tr>    </table>   </td>  </tr>
> </table> </center> <p align="center">   <font size="-1">   Copyright
> (c) 1999-2000 <a href="http://xml.apache.org">The Apache XML
> Project</a>.<br>   All rights reserved.   </font> </p> </body> </html>