RE: request taglib + query

2001-08-14 Thread Morrison, John

The logicsheets are prob being applied in the wrong order... try

esql:query
  select name as reg_name,
 deviceID as reg_deviceID,
 description as reg_description,
 startTime as reg_startTime,
 endTime as reg_endTime
  from user, terminal, deviceType, registration
  where terminal.userID =
xsp:exprrequest.getParameter(userID)[0]/xsp:expr
and user.userID = terminal.userID
and deviceType.deviceType = terminal.deviceType
and registration.terminalID = terminal.terminalID;
/esql:query

There are several 'variables' available in the java src for you to use
directly, take a look in the generated java.

J.

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, 14 August 2001 10:23 am
 To: [EMAIL PROTECTED]
 Subject: request taglib + query
 
 
 Hi all,
 
 and thanks for helping me so much!
 
 Unfortunately, I still cannot get my page to do what I want:
 
 *I am able to pick up the http request parameter from the URL 
 and display it
 *I am able to run the query if I hardcode the value
 *But I am not able to run the query with the value that I 
 pick up from the
 URL!
 
 I have also included the xml file and the generated java 
 code. It looks fine
 to me. You can see that I have put a request in the xml 
 document just to
 display, and this displays OK on the screen. But for some 
 reason it won't
 work in the query... The java code generated in each case is 
 the same, isn't
 it?
 
 *I have tried with ?userID=55512345
?userID='55512345'
?userID=55512345
 *I have tried to have the database field as a string and as an integer
 *Using xsp-request instead of request doesn't work (I think 
 maybe that's for
 C2?)
 *I have tried EVERY other suggestion that I have received, 
 but with no luck
 
 I guess the reason must be that the query is attempted run BEFORE the
 parameter is found. Does anybody have any idea how I can work 
 around this to
 use the parameter in the query?
 
 I would also like to try to store the parameter in a 
 variable, and then try
 and use the variable in the query to see if that works. Does 
 anybody now how
 I can do that? Christopher and Max, you both had an idea of 
 building the
 query as a string with xsp:logic, but I am not able to do it 
 right! If I try
 to use request.GetParameter I get error messages...
 
 Thanks again!
 
 Regards
 Anne Marie
 
 Welcome.xml:
 
 ?xml version=1.0 standalone=no?
 ?xml-stylesheet href=welcome-html.xsl type=text/xsl?
 ?xml-stylesheet href=welcome-wml.xsl type=text/xsl media=wap?
 
 ?cocoon-process type=xsp?
 ?cocoon-process type=xslt?
 
 !-- Welcome.xml --
 !-- Written by Anne Marie Hartvigsen --
 
 !DOCTYPE document [
   !ENTITY email [EMAIL PROTECTED]
 ]
 
 xsp:page language=java
   xmlns:xsp=http://www.apache.org/1999/XSP/Core;
   xmlns:esql=http://apache.org/cocoon/SQL/v2;
   xmlns:request=http://www.apache.org/1999/XSP/Request;
 
 
 document
   head
 pagetitle title=Titleinfo/ 
   /head
 
   body
 h1
   Welcome,
   request:get-parameter name=userID/
 /h1
 
 p
   Below the query results should be displayed.
 /p
 p/
 
 br/br 
 
 reg_data
 esql:connection
 
   esql:pool
 annemarie
   /esql:pool
 
   esql:execute-query
 esql:query
   select name as reg_name,
  deviceID as reg_deviceID,
  description as reg_description,
  startTime as reg_startTime,
  endTime as reg_endTime
   from user, terminal, deviceType, registration
   where terminal.userID = request:get-parameter name=userID/
 and user.userID = terminal.userID
 and deviceType.deviceType = terminal.deviceType
 and registration.terminalID = terminal.terminalID;
 /esql:query
 esql:results
   header
 These are your registrations,
   /header
   esql:row-results
 username
   esql:get-string column=reg_name/
 /username
 registration
   deviceID
 esql:get-string column=reg_deviceID/
   /deviceID
   description
 esql:get-string column=reg_description/
   /description
   startTime
 esql:get-string column=reg_startTime/
   /startTime
   endTime
 esql:get-string column=reg_endTime/
   /endTime
 /registration
   /esql:row-results
 /esql:results
   /esql:execute-query
 /esql:connection
 
 /reg_data
 
 
 
  br/br
 
 signature
   Made by: email;
 /signature
   /body
 /document
 /xsp:page
 
 ---
 
 welcome.java:
 
 package _var._tomcat._webapps._cocoon._vt._welcome;
 
 import java.io.*;
 import java.net.*;
 import java.util.*;
 import org.w3c.dom.*;
 import org.xml.sax.*;
 import javax.servlet.*;
 

Re: request taglib + query

2001-08-14 Thread Christian Haul

Anne Marie,

as far as I can see, the resulting java source is OK. A comparison of
the two fragments that reference the request parameter are identical
which they should be as both return a String.

On 14.Aug.2001 -- 11:22 AM, [EMAIL PROTECTED] wrote:

Printing ID to greet the user:

 xspCurrentNode.appendChild(
   xspExpr(
   XSPRequestLibrary.getParameter(
 request,
   String.valueOf(userID),
 null
   )
 , document)
 );

Using the ID for the query:

 _esql_query.query = String.valueOf(
   
   
 +select name as reg_name,  deviceID as
 reg_deviceID,  description as reg_description,
 startTime as reg_startTime,  endTime as reg_endTime   from
 user, terminal, deviceType, registration   where terminal.userID = 
   
 + 
   XSPRequestLibrary.getParameter(
 request,
   String.valueOf(userID),
 null
   )
 
 +  and user.userID = terminal.userID
 and deviceType.deviceType = terminal.deviceType and
 registration.terminalID = terminal.terminalID; 
   );

AFAICS this should run the query with the supplied parameter. 

Could you please
a) state what you expect and what happens instead
b) report all error messages
c) report the sql error message when using esql:parameter/
   Hint: esql:error-results/ / esql:get-message/
d) check that a manual query with the exact query string (including
   all spaces!) does produce the correct result
e) not open new threads for the same problem

Although I do not expect this to have an impact, see if

xsp:logic
String myQuery=. + xsp-request:parameter name=userID/ + ...;
/xsp:logic
[...]
pQuery is prexsp:exprmyQuery/xsp:expr/pre/p
[...]
esql:queryxsp:exprmyQuery/xsp:expr/esql:query

does change anything.

Chris.

-- 
C h r i s t i a n   H a u l
[EMAIL PROTECTED]
fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

-
Please check that your question has not already been answered in the
FAQ before posting. http://xml.apache.org/cocoon/faqs.html

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: request taglib + query

2001-08-14 Thread Christopher Painter-Wakefield


Anne Marie,

this may sound completely stupid, but remove the semicolon at the end of
your query.  I copied your XML into a new file in my project and edited it
to make the query match tables in my database and changed the pool to one
of my own pools.  I also removed your stylesheets and used a simple source
formatter stylesheet.  I made no other changes.  When I ran the query with
an appropriate parameter, I got no results.  When I edited the file to
remove the semicolon, I got results.  Just to make sure, I added the
semicolon back in, and sure enough, I got no results again.  Perhaps this
is some JDBC thing.  I do know that all of the working examples I have
seen, and all of the queries in my own code, are not terminated in any way.

-Christopher




Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:

Subject:  request taglib + query


Hi all,

and thanks for helping me so much!

Unfortunately, I still cannot get my page to do what I want:

*I am able to pick up the http request parameter from the URL and display
it
*I am able to run the query if I hardcode the value
*But I am not able to run the query with the value that I pick up from the
URL!

I have also included the xml file and the generated java code. It looks
fine
to me. You can see that I have put a request in the xml document just to
display, and this displays OK on the screen. But for some reason it won't
work in the query... The java code generated in each case is the same,
isn't
it?

*I have tried with ?userID=55512345
   ?userID='55512345'
   ?userID=55512345
*I have tried to have the database field as a string and as an integer
*Using xsp-request instead of request doesn't work (I think maybe that's
for
C2?)
*I have tried EVERY other suggestion that I have received, but with no luck

I guess the reason must be that the query is attempted run BEFORE the
parameter is found. Does anybody have any idea how I can work around this
to
use the parameter in the query?

I would also like to try to store the parameter in a variable, and then try
and use the variable in the query to see if that works. Does anybody now
how
I can do that? Christopher and Max, you both had an idea of building the
query as a string with xsp:logic, but I am not able to do it right! If I
try
to use request.GetParameter I get error messages...

Thanks again!

Regards
Anne Marie

Welcome.xml:

?xml version=1.0 standalone=no?
?xml-stylesheet href=welcome-html.xsl type=text/xsl?
?xml-stylesheet href=welcome-wml.xsl type=text/xsl media=wap?

?cocoon-process type=xsp?
?cocoon-process type=xslt?

!-- Welcome.xml --
!-- Written by Anne Marie Hartvigsen --

!DOCTYPE document [
  !ENTITY email [EMAIL PROTECTED]
]

xsp:page language=java
  xmlns:xsp=http://www.apache.org/1999/XSP/Core;
  xmlns:esql=http://apache.org/cocoon/SQL/v2;
  xmlns:request=http://www.apache.org/1999/XSP/Request;


document
  head
pagetitle title=Titleinfo/
  /head

  body
h1
  Welcome,
  request:get-parameter name=userID/
/h1

p
  Below the query results should be displayed.
/p
p/

br/br

reg_data
esql:connection

  esql:pool
annemarie
  /esql:pool

  esql:execute-query
esql:query
  select name as reg_name,
 deviceID as reg_deviceID,
 description as reg_description,
 startTime as reg_startTime,
 endTime as reg_endTime
  from user, terminal, deviceType, registration
  where terminal.userID = request:get-parameter name=userID/
and user.userID = terminal.userID
and deviceType.deviceType = terminal.deviceType
and registration.terminalID = terminal.terminalID;
/esql:query
esql:results
  header
These are your registrations,
  /header
  esql:row-results
username
  esql:get-string column=reg_name/
/username
registration
  deviceID
esql:get-string column=reg_deviceID/
  /deviceID
  description
esql:get-string column=reg_description/
  /description
  startTime
esql:get-string column=reg_startTime/
  /startTime
  endTime
esql:get-string column=reg_endTime/
  /endTime
/registration
  /esql:row-results
/esql:results
  /esql:execute-query
/esql:connection

/reg_data



 br/br

signature
  Made by: email;
/signature
  /body
/document
/xsp:page






-
Please check that your question has not already been answered in the
FAQ before posting. http://xml.apache.org/cocoon/faqs.html

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]