You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Matthew Cordes <mc...@maine.edu> on 2000/08/29 23:38:53 UTC
Dynamic sql Query
Hello all.
I'm having a bit of trouble understanding how xsp and java interact.
I have a sql query that i wish to augment based upon request parameters.
Here is an example:
<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="page.xsl" type="text/xsl"?>
<xsp:page
language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:sql="I can't recall the sql namespace, but its correct in my code"
xmlns:request="http://www.apache.org/1999/XSP/Request"
>
<xsp:logic>
String name = String.valueOf( <request:get-parameter name="name"/> );
String age = String.valueOf( <request:get-parameter name="age"/> );
String where = "";
if ( name != null && !name.equals(""))
where = " name is not null";
else if ( age != null && !name.equals(""))
where = " age is not null";
</xsp:logic>
<page>
<!-- i left out the driver, etc for brevity -->
<sql:execute-query>
<sql:query>
select name, age, occupation, etc from sometable
where <xsp:expr>where</xsp:expr>
<sql:query>
</sql:query>
</page>
</xsp:page>
This is an oversimplified example, but you see what I'm trying to do.
I want to construct a java string and then pass it to the sqltaglib.
The problem is I'm told 'request' is undefined upon compilation
of the xsp:logic block above. The 'where' is also undefined in the
sql:execute-query block.
Any ideas?
-matt
Re: Taglib Documentation...
Posted by Stefano Mazzocchi <st...@apache.org>.
Per Kreipke wrote:
>
> Not sure if anyone else will find this useful but I got tired of reading
> through the source XSL files to find out what 'functions' were in each
> taglib. And I couldn't find any other documentation (I did ask this list
> earlier).
>
> Attached are an XSP page and a XSLT stylesheet which read taglib XSL files
> (like cookie.xsl) and write out HTML listing each 'function' within.
> [Attached: tagdocs.xml and tagdocs.xsl]
>
> If you drop them in a Cocoon directory, make one small code change and bring
> it up in a browser as follows, it will 'document' [no, it doesn't exctract
> english comments, there really weren't any :) ] the selected taglib.
>
> Example:
>
> http://localhost/coocoon/tagdocs.xml?file=cookie.xsl
>
> to list all the available 'functions' in the cookie taglib.
>
> The one line of code that needs to change (or perhaps not), is the location
> of the taglib files relative to your servlet engine.
>
> - Open tagdocs.xml.
> - Search for the variable 'baseDir'.
> - Change the relative path which follows to point to your cocoon
> distribution.
>
> It's currently set for my local install of cocoon 1.7.4, you should only
> have to change some of the front of the path.
>
> Hope you find it helpful,
>
> Per.
>
> P.s. Thanks to the Cocoon team for writing and enforcing excellent patterns
> in the taglibs! Very elegant, though a little terse ;-)
>
> ------------------------------------------------------------------------
> Name: tagdocs.xml
> tagdocs.xml Type: XML Document (text/xml)
> Encoding: quoted-printable
>
> Name: tagdocs.xsl
> tagdocs.xsl Type: XML Document (text/xml)
> Encoding: quoted-printable
>
> ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
Sounds great. I'll add this to the samples.
--
Stefano Mazzocchi One must still have chaos in oneself to be
able to give birth to a dancing star.
<st...@apache.org> Friedrich Nietzsche
--------------------------------------------------------------------
Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------
Re: Taglib Documentation...
Posted by Jens Lorenz <je...@interface-business.de>.
From: Per Kreipke <pe...@onclave.com>
To: <co...@xml.apache.org>
Sent: Wednesday, August 30, 2000 1:29 AM
Subject: Taglib Documentation...
> Hope you find it helpful,
I followed your instructions and it worked ... And it's really helpful
because I'm also tired of staring at the taglib stylesheets to figure out
the functions and parameters ...
> Per.
Bye.
Jens
--
jens.lorenz@interface-business.de
interface-business GmbH \\|//
Tolkewitzer Strasse 49 (o o)
01277 Dresden ~~~~oOOo~(_)~oOOo~~~~
Germany
Taglib Documentation...
Posted by Per Kreipke <pe...@onclave.com>.
Not sure if anyone else will find this useful but I got tired of reading
through the source XSL files to find out what 'functions' were in each
taglib. And I couldn't find any other documentation (I did ask this list
earlier).
Attached are an XSP page and a XSLT stylesheet which read taglib XSL files
(like cookie.xsl) and write out HTML listing each 'function' within.
[Attached: tagdocs.xml and tagdocs.xsl]
If you drop them in a Cocoon directory, make one small code change and bring
it up in a browser as follows, it will 'document' [no, it doesn't exctract
english comments, there really weren't any :) ] the selected taglib.
Example:
http://localhost/coocoon/tagdocs.xml?file=cookie.xsl
to list all the available 'functions' in the cookie taglib.
The one line of code that needs to change (or perhaps not), is the location
of the taglib files relative to your servlet engine.
- Open tagdocs.xml.
- Search for the variable 'baseDir'.
- Change the relative path which follows to point to your cocoon
distribution.
It's currently set for my local install of cocoon 1.7.4, you should only
have to change some of the front of the path.
Hope you find it helpful,
Per.
P.s. Thanks to the Cocoon team for writing and enforcing excellent patterns
in the taglibs! Very elegant, though a little terse ;-)
Re: Dynamic sql Query
Posted by Matthew Cordes <mc...@maine.edu>.
That worked great thanks
-matt
On Tue, Aug 29, 2000 at 05:47:53PM -0400, sudhi wrote:
> Hi,
> try moving ur xsp:login inside page, and inside xsp logic u can use
> request.getParameter() directly.
>
> HTH
> Sudhi
>
> Matthew Cordes wrote:
> >
> > Hello all.
> >
> > I'm having a bit of trouble understanding how xsp and java interact.
> > I have a sql query that i wish to augment based upon request parameters.
> > Here is an example:
> >
> > <?xml version="1.0"?>
> >
> > <?cocoon-process type="xsp"?>
> > <?cocoon-process type="xslt"?>
> > <?xml-stylesheet href="page.xsl" type="text/xsl"?>
> >
> > <xsp:page
> > language="java"
> > xmlns:xsp="http://www.apache.org/1999/XSP/Core"
> > xmlns:sql="I can't recall the sql namespace, but its correct in my code"
> > xmlns:request="http://www.apache.org/1999/XSP/Request"
> > >
> >
> > <xsp:logic>
> > String name = String.valueOf( <request:get-parameter name="name"/> );
> > String age = String.valueOf( <request:get-parameter name="age"/> );
> > String where = "";
> >
> > if ( name != null && !name.equals(""))
> > where = " name is not null";
> >
> > else if ( age != null && !name.equals(""))
> > where = " age is not null";
> > </xsp:logic>
> >
> >
> > <page>
> > <!-- i left out the driver, etc for brevity -->
> > <sql:execute-query>
> > <sql:query>
> > select name, age, occupation, etc from sometable
> > where <xsp:expr>where</xsp:expr>
> > <sql:query>
> > </sql:query>
> > </page>
> >
> > </xsp:page>
> >
> > This is an oversimplified example, but you see what I'm trying to do.
> > I want to construct a java string and then pass it to the sqltaglib.
> >
> > The problem is I'm told 'request' is undefined upon compilation
> > of the xsp:logic block above. The 'where' is also undefined in the
> > sql:execute-query block.
> >
> > Any ideas?
> >
> > -matt
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
Re: Dynamic sql Query
Posted by sudhi <su...@insage.com>.
Hi,
try moving ur xsp:login inside page, and inside xsp logic u can use
request.getParameter() directly.
HTH
Sudhi
Matthew Cordes wrote:
>
> Hello all.
>
> I'm having a bit of trouble understanding how xsp and java interact.
> I have a sql query that i wish to augment based upon request parameters.
> Here is an example:
>
> <?xml version="1.0"?>
>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="page.xsl" type="text/xsl"?>
>
> <xsp:page
> language="java"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core"
> xmlns:sql="I can't recall the sql namespace, but its correct in my code"
> xmlns:request="http://www.apache.org/1999/XSP/Request"
> >
>
> <xsp:logic>
> String name = String.valueOf( <request:get-parameter name="name"/> );
> String age = String.valueOf( <request:get-parameter name="age"/> );
> String where = "";
>
> if ( name != null && !name.equals(""))
> where = " name is not null";
>
> else if ( age != null && !name.equals(""))
> where = " age is not null";
> </xsp:logic>
>
>
> <page>
> <!-- i left out the driver, etc for brevity -->
> <sql:execute-query>
> <sql:query>
> select name, age, occupation, etc from sometable
> where <xsp:expr>where</xsp:expr>
> <sql:query>
> </sql:query>
> </page>
>
> </xsp:page>
>
> This is an oversimplified example, but you see what I'm trying to do.
> I want to construct a java string and then pass it to the sqltaglib.
>
> The problem is I'm told 'request' is undefined upon compilation
> of the xsp:logic block above. The 'where' is also undefined in the
> sql:execute-query block.
>
> Any ideas?
>
> -matt
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: Dynamic sql Query
Posted by Donald Ball <ba...@webslingerZ.com>.
On Tue, 29 Aug 2000, Matthew Cordes wrote:
> Hello all.
>
> I'm having a bit of trouble understanding how xsp and java interact.
> I have a sql query that i wish to augment based upon request parameters.
> Here is an example:
>
> <?xml version="1.0"?>
>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="page.xsl" type="text/xsl"?>
>
> <xsp:page
> language="java"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core"
> xmlns:sql="I can't recall the sql namespace, but its correct in my code"
> xmlns:request="http://www.apache.org/1999/XSP/Request"
> >
>
> <xsp:logic>
> String name = String.valueOf( <request:get-parameter name="name"/> );
> String age = String.valueOf( <request:get-parameter name="age"/> );
> String where = "";
>
> if ( name != null && !name.equals(""))
> where = " name is not null";
>
> else if ( age != null && !name.equals(""))
> where = " age is not null";
> </xsp:logic>
>
>
> <page>
> <!-- i left out the driver, etc for brevity -->
> <sql:execute-query>
> <sql:query>
> select name, age, occupation, etc from sometable
> where <xsp:expr>where</xsp:expr>
> <sql:query>
> </sql:query>
> </page>
>
> </xsp:page>
>
> This is an oversimplified example, but you see what I'm trying to do.
> I want to construct a java string and then pass it to the sqltaglib.
>
> The problem is I'm told 'request' is undefined upon compilation
> of the xsp:logic block above. The 'where' is also undefined in the
> sql:execute-query block.
just move the <xsp:logic> block underneath <page>.
- donald