Yes, I am doing that right now. But the people using the app that I am writing don't want type 01/30/2003 to get the reports. The main reason is that the company that I am working for is in Germany. So the user wants to put 30.01.2003 in the form.
If I parse that into the esql I can't get any data out of db. I thought about client-side JavaScript to transform the date and then parse it, but I hoped that I could transform it on the server side with xsp. You said something about: simply invert the process on the SimpleDateFormat object. How would I do that? -----Ursprüngliche Nachricht----- Von: Andrew Timberlake [mailto:[EMAIL PROTECTED]] Gesendet: Freitag, 31. Januar 2003 16:50 An: [EMAIL PROTECTED] Betreff: Re: AW: AW: AW: AW: xsp-element equivalent to xsl:param? Thank you for the compliment but it was only through bumping my head against many a brick wall that I learned anything. To convert your string into a Date object, you simply invert the process on the SimpleDateFormat object Date myDate = (new SimpleDateFormat("MM/dd/yyyy")).parse(request.getParameter("date")); This method needs the request parameter to arrive in the correct format though and therefore invalidates the need to format the date in the way you been up until now. Now this is where the <esql:parameter> tag comes in handy. Instead of using the #Formated dat string# format you can pass the date object directly to the esql parameter: <esql:parameter><xsp:expr>myDate</xsp:expr></esql:parameter> Andrew On Fri, 2003-01-31 at 17:40, Scherler, Thorsten wrote: > You're patience and so brilliant: > sitemap.log: > ERROR (2003-01-31) 16:36.32:707 [sitemap.generator.serverpages] >(/weidmueller-dev/IDC2/info_int.xml) Thread-9/IDC2_info_int_xsp: XSP date error: > java.lang.IllegalArgumentException: Cannot format given Object as a Date > at java.text.DateFormat.format(DateFormat.java:265) > at java.text.Format.format(Format.java:116) > > now you wrote: > If there is an error being thrown, then you are going to have to change > the request parameter value into a valid java.util.Date object. > > my question: How? <- I am so stupid when it comes to Java (or maybe in general ;-)) > > -----Ursprüngliche Nachricht----- > Von: Andrew Timberlake [mailto:[EMAIL PROTECTED]] > Gesendet: Freitag, 31. Januar 2003 16:27 > An: [EMAIL PROTECTED] > Betreff: Re: AW: AW: AW: xsp-element equivalent to xsl:param? > > > I think that the request parameter is returning a string and the format > object is expecting a Date object. (I should have recognised this > earlier). > I think the XSP page is throwing an exception which we have been > ignoring. Try the following code and then check the sitemap.log and > errors.log (can't remember which one) file in /WEB-INF/logs/ for the > exception. You can do a find in the log file for "XSP date error" to > locate the error. > If there is an error being thrown, then you are going to have to change > the request parameter value into a valid java.util.Date object. > > ... > <dataset> > <xsp:logic> > String timeOfDay = ""; > try{ > timeOfDay = (new > SimpleDateFormat("MM/dd/yyyy")).format(request.getParameter("date")); > }catch(Exception e){ > getLogger().error("XSP date error: ", e); > } > </xsp:logic> > > > On Fri, 2003-01-31 at 17:13, Scherler, Thorsten wrote: > > Thanks, > > > > but now I am not getting any results because is always timeOfDay = "". > > > > I will look into using <esql:parameter> tags. > > > > Thanks for your patience. > > > > -----Ursprüngliche Nachricht----- > > Von: Andrew Timberlake [mailto:[EMAIL PROTECTED]] > > Gesendet: Freitag, 31. Januar 2003 16:07 > > An: [EMAIL PROTECTED] > > Betreff: Re: AW: AW: xsp-element equivalent to xsl:param? > > > > > > Try this > > > > ... > > <dataset> > > <xsp:logic> > > String timeOfDay = ""; > > try{ > > timeOfDay = (new > > SimpleDateFormat("MM/dd/yyyy")).format(request.getParameter("date")); > > }catch(Exception e){} > > </xsp:logic> > > > > <esql:connection> > > <esql:pool>IDC2_int</esql:pool> > > <esql:execute-query> > > <esql:query> > > select * from info_bericht where country ='<xsp-request:get-parameter > > name="GETcountry"/>' AND Info_datum = > > #<xsp:expr>timeOfDay</xsp:expr># > > </esql:query> > > > > I will mention again that you should look into using <esql:parameter> > > tags. > > > > Andrew > > > > On Fri, 2003-01-31 at 16:46, Scherler, Thorsten wrote: > > > Hello Andrew, > > > > > > my final xsp should look like this: > > > ... > > > <dataset> > > > <xsp:logic> > > > try{ > > > String timeOfDay = (new > > > SimpleDateFormat("MM/dd/yyyy")).format(request.getParameter("date")); > > > }catch(Exception e){} > > > </xsp:logic> > > > <esql:connection> > > > <esql:pool>IDC2_int</esql:pool> > > > <esql:execute-query> > > > <esql:query> > > > select * from info_bericht where country ='<xsp-request:get-parameter >name="GETcountry"/>' AND Info_datum = #<xsp:expr>timeOfDay</xsp:expr># > > > </esql:query> > > > ... > > > > > > like I stated before, as soon I get rid off the logic my query is successful. > > > > > > Like you told me before my method now starts after the first xml element: > > > > > > snip from IDC2_info_int_xsp.java > > > /** > > > * Generate XML data. > > > */ > > > public void generate() throws SAXException, IOException, ProcessingException { > > > this.contentHandler.startDocument(); > > > AttributesImpl xspAttr = new AttributesImpl(); > > > > > > ... > > > > > > this.contentHandler.startElement( > > > "", > > > "dataset", > > > "dataset", > > > xspAttr > > > ); > > > xspAttr.clear(); > > > > > > > > > this.characters("\n "); > > > > > > try{ > > > String timeOfDay = (new > > > SimpleDateFormat("MM/dd/yyyy")).format(request.getParameter("date")); > > > }catch(Exception e){} > > > > > > this.characters("\n\t\t"); > > > ... > > > > > > > > > -----Ursprüngliche Nachricht----- > > > Von: Andrew Timberlake [mailto:[EMAIL PROTECTED]] > > > Gesendet: Freitag, 31. Januar 2003 15:30 > > > An: [EMAIL PROTECTED] > > > Betreff: Re: AW: xsp-element equivalent to xsl:param? > > > > > > > > > On Fri, 2003-01-31 at 16:09, Scherler, Thorsten wrote: > > > > Hello Jan, > > > > > > > > I couldn't find the error. > > > > > > > > But I attached it. > > > > > > > I was reading your previous post in which you posted your xsp source. > > > Instead of this: > > > <esql:execute-query> > > > <esql:query> > > > select * from info_bericht where country ='<xsp-request:get-parameter > > > name="GETcountry"/>' AND Info_datum = #<xsp-request:get-parameter name="date"/># > > > </esql:query> > > > > > > Try this: > > > <esql:execute-query> > > > <esql:query> > > > select * from info_bericht where country = ><esql:parameter><xsp-request:get-parameter > > > name="GETcountry"/></esql:parameter> AND Info_datum = ><esql:parameter><xsp-request:get-parameter name="date"/></esql:parameter> > > > </esql:query> > > > > > > This will then use a PreparedStatement which is safer from possible SQL exploit. > > > > > > Other than that, the XSP source didn't show where you were using the direct >access to parameters.getParameter() or request.getParameter() > > > > > > Andrew > > > > > > Andrew > > > > > > > > > --------------------------------------------------------------------- > > > Please check that your question has not already been answered in the > > > FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> > > > > > > To unsubscribe, e-mail: <[EMAIL PROTECTED]> > > > For additional commands, e-mail: <[EMAIL PROTECTED]> > > > > > > > > > --------------------------------------------------------------------- > > > Please check that your question has not already been answered in the > > > FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> > > > > > > To unsubscribe, e-mail: <[EMAIL PROTECTED]> > > > For additional commands, e-mail: <[EMAIL PROTECTED]> -- Andrew Timberlake <[EMAIL PROTECTED]> --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]> --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>