cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <ba...@webslingerZ.com>
Subject Re: Dynamic sql Query
Date Tue, 29 Aug 2000 22:03:28 GMT
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 &amp;&amp; !name.equals(""))
> 		where = " name is not null";
> 
> 	else if ( age != null &amp;&amp; !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


Mime
View raw message