XSP TransformCustomDate [was: Re: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?]

2003-02-02 Thread Scherler, Thorsten
Hello everyone,

after all the help I received from you I wrote a little How-to about transforming a 
custom date string to a valid Java Date object.

Please have a look at http://wiki.cocoondev.org/Wiki.jsp?page=XSPTransformCustomDate.

It is more or less the conclusion off the thread "xsp-element equivalent to 
xsl:param?" and some other that I have posted in regards to the topic.
I would like to thank especially Andrew Timberlake for being so patient.

Hope that will cut down developing time for you ;-).

King regards


> Mit freundlichem Gruss,
> 
> Thorsten Scherler
> Marketing / Telefonmarketing
> 
> Weidmüller GmbH & Co.
> P.O. Box 2807
> 33058 Paderborn
> Tel.:+ 49 - 5252-960-350
> Fax:+ 49 - 5252-960-116
> eMail: [EMAIL PROTECTED]
> http://www.weidmueller.de
> 
> 

-
Please check that your question  has not already been answered in the
FAQ before posting. 

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




Re: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

2003-02-02 Thread Andrew Timberlake
Thorsten

On Sun, 2003-02-02 at 05:27, Thorsten Scherler wrote:
> Hello Andrew,
> 
> how is weather in SA? Here in Germany it is snowing!
Here it is hotter than I have experienced for many years.

What problem are you still experiencing?
The code you included produced the following results when run with the
querystring date=01.02.2003


   01.02.2003
   Sat Feb 01 00:00:00 SAST 2003
   31.01.2002


-- 
Andrew

I have never let my schooling interfere with my education.
--Mark Twain


-
Please check that your question  has not already been answered in the
FAQ before posting. 

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




Re: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

2003-02-01 Thread Thorsten Scherler
Hello Andrew,

how is weather in SA? Here in Germany it is snowing!

Please see my answer below:


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.


So to avoid worring about the format the user uses,
I could use a JavaScript with my html-Form:
1) 31.01.2003
2) transform that date before submit -> result: 01/31/2003
3) request it with ?date=01/31/2003
4) ...and had no problems.

I'm not sure if you've understood the  concept fully.
Using the esql parameter will result in java code that looks something
like the following:

...

When using code like this, you don't have to worry about the format the
database engine uses, you only have to worry about the format the user
uses and parse that into a Date object.


You are right! I think that is the actual problem.

The parsed date in the request (?date=01/31/03) is a string!

That was the conclusion the let me to the following code (date.xsp). I 
assume the request is ?date=30.01.2002 (datePattern = "dd.MM.").

http://apache.org/xsp";>

java.util.*
java.text.*



String datePattern = "dd.MM.";
SimpleDateFormat dateFormat = new SimpleDateFormat( datePattern );
String sDate_one = "31.01.2002";
String sDate_two = request.getParameter("date");
Date date_one = null;
try
   {
   date_one = dateFormat.parse( sDate_two );
   }
   catch( ParseException e )
   {
 getLogger().error("XSP date error: ", e);
}


sDate_two


date_one


sDate_one




Thanks again for all the help and your time!

King regards
Thorsten
http://apache.org/xsp";>

java.util.*
java.text.*



 String datePattern = "dd.MM.";
   SimpleDateFormat dateFormat = new SimpleDateFormat( datePattern );
   
   String sDate_one = "31.01.2002";
   String sDate_two = request.getParameter("date");
   
   Date date_one = null;
try
   {
   date_one = dateFormat.parse( sDate_two );
   }
   catch( ParseException e )
   {
 getLogger().error("XSP date error: ", e);
}   


sDate_two


date_one


sDate_one





-
Please check that your question  has not already been answered in the
FAQ before posting. 

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


AW: AW: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

2003-01-31 Thread Scherler, Thorsten
Last Mail before I stop work:

If I modify the code of Judith like that:
...
 Date myDate = null;
...

instead of Date myDate = "";

I do not get an error now, but neither the "date".

So thanks everybody for your help.

I will finish up after 14hours without solving the problem.

King regards
-Ursprüngliche Nachricht-
Von: Scherler, Thorsten 
Gesendet: Freitag, 31. Januar 2003 18:11
An: [EMAIL PROTECTED]
Betreff: AW: AW: AW: AW: AW: AW: AW: xsp-element equivalent to
xsl:param?


I tried:
http://apache.org/xsp"; 
xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
xmlns:xsp-request="http://apache.org/xsp/request/2.0";>


  Date myDate = "";
  String dateParam = null;

  try{
myDate = (new 
SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
   dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
  } catch(Exception e){
getLogger().error("XSP date error: ", e);
  }
   

dateParam




error:
description org.apache.cocoon.ProcessingException: Language Exception: 
org.apache.cocoon.components.language.LanguageException: Error compiling 
IDC2_info_int_xsp: Line 286, column -1: incompatible types Line 0, column 0: 1 error 


  IDC2_info_int_xsp.java: 
this.characters("\n\t\t\t");
  
  Date myDate = "";
  String dateParam = null;
  try{
myDate = (new 
SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
   dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
  } catch(Exception e){
getLogger().error("XSP date error: ", e);
  }
   
this.characters("\n\t\t\t");
  



Bye
Judith

> -Ursprüngliche Nachricht-----
> Von:  Scherler, Thorsten [SMTP:[EMAIL PROTECTED]]
> Gesendet am:  Freitag, 31. Januar 2003 18:01
> An:   [EMAIL PROTECTED]
> Betreff:  AW: AW: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?
> 
> I correct it and now:
> 
> description org.apache.cocoon.ProcessingException: Language Exception: 
>org.apache.cocoon.components.language.LanguageException: Error compiling 
>IDC2_info_int_xsp: Line 286, column -1: incompatible types Line 309, column 48: 
>variable dateParam not found in class org.apache.cocoon.www.logic.IDC2_info_int_xsp 
>Line 0, column 0: 2 errors 
> 
> the xsp:
> http://apache.org/xsp"; 
>xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
>xmlns:xsp-request="http://apache.org/xsp/request/2.0";>
>   
>   
>   Date myDate = "";
>   try{
> myDate = (new SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
> String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
>   }catch(Exception e){
> getLogger().error("XSP date error: ", e);
> }
>
>       
>   dateParam
>   
>   
> 
> 
> the request: ?date=31.01.2003
> 
> -Ursprüngliche Nachricht-
> Von: Andrew Timberlake [mailto:[EMAIL PROTECTED]]
> Gesendet: Freitag, 31. Januar 2003 17:49
> An: [EMAIL PROTECTED]
> Betreff: Re: AW: AW: AW: AW: AW: AW: xsp-element equivalent to
> xsl:param?
> 
> 
> On Fri, 2003-01-31 at 18:37, Scherler, Thorsten wrote:
> > Hello again,
> > 
> > I have shorten the xsp:
> > http://apache.org/xsp"; 
>xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
>xmlns:xsp-request="http://apache.org/xsp/request/2.0";>
> > 
> > 
> > Date myDate = "";
> > try{
> > myDate = (new
> > SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
>  ---^
> You had a missing ')'
> 
> > String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
> >   }catch(Exception e){
> > getLogger().error("XSP date error: ", e);
> > }
> > 
> > 
> > myDate 
> > 
> > 
> > 
> > 
> 
> -- 
> 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

AW: AW: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

2003-01-31 Thread Scherler, Thorsten
I tried:
http://apache.org/xsp"; 
xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
xmlns:xsp-request="http://apache.org/xsp/request/2.0";>


  Date myDate = "";
  String dateParam = null;

  try{
myDate = (new 
SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
   dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
  } catch(Exception e){
getLogger().error("XSP date error: ", e);
  }
   

dateParam




error:
description org.apache.cocoon.ProcessingException: Language Exception: 
org.apache.cocoon.components.language.LanguageException: Error compiling 
IDC2_info_int_xsp: Line 286, column -1: incompatible types Line 0, column 0: 1 error 


  IDC2_info_int_xsp.java: 
this.characters("\n\t\t\t");
  
  Date myDate = "";
  String dateParam = null;
  try{
myDate = (new 
SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
   dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
  } catch(Exception e){
getLogger().error("XSP date error: ", e);
  }
   
this.characters("\n\t\t\t");
  



Bye
Judith

> -Ursprüngliche Nachricht-
> Von:  Scherler, Thorsten [SMTP:[EMAIL PROTECTED]]
> Gesendet am:  Freitag, 31. Januar 2003 18:01
> An:   [EMAIL PROTECTED]
> Betreff:  AW: AW: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?
> 
> I correct it and now:
> 
> description org.apache.cocoon.ProcessingException: Language Exception: 
>org.apache.cocoon.components.language.LanguageException: Error compiling 
>IDC2_info_int_xsp: Line 286, column -1: incompatible types Line 309, column 48: 
>variable dateParam not found in class org.apache.cocoon.www.logic.IDC2_info_int_xsp 
>Line 0, column 0: 2 errors 
> 
> the xsp:
> http://apache.org/xsp"; 
>xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
>xmlns:xsp-request="http://apache.org/xsp/request/2.0";>
>   
>   
>   Date myDate = "";
>   try{
> myDate = (new SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
> String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
>   }catch(Exception e){
> getLogger().error("XSP date error: ", e);
> }
>    
>       
>       dateParam
>   
>   
> 
> 
> the request: ?date=31.01.2003
> 
> -Ursprüngliche Nachricht-
> Von: Andrew Timberlake [mailto:[EMAIL PROTECTED]]
> Gesendet: Freitag, 31. Januar 2003 17:49
> An: [EMAIL PROTECTED]
> Betreff: Re: AW: AW: AW: AW: AW: AW: xsp-element equivalent to
> xsl:param?
> 
> 
> On Fri, 2003-01-31 at 18:37, Scherler, Thorsten wrote:
> > Hello again,
> > 
> > I have shorten the xsp:
> > http://apache.org/xsp"; 
>xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
>xmlns:xsp-request="http://apache.org/xsp/request/2.0";>
> > 
> > 
> > Date myDate = "";
> > try{
> > myDate = (new
> > SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
>  ---^
> You had a missing ')'
> 
> > String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
> >   }catch(Exception e){
> > getLogger().error("XSP date error: ", e);
> > }
> > 
> > 
> > myDate 
> > 
> > 
> > 
> > 
> 
> -- 
> 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]>
> 

-
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]>




AW: AW: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

2003-01-31 Thread Andres, Judith
Hi Thorsten,

you define the variable dateParam inside a try/catch-block. When you reference to it 
outside of this block you're out of scope.

try:
http://apache.org/xsp"; 
xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
xmlns:xsp-request="http://apache.org/xsp/request/2.0";>


  Date myDate = "";
  String dateParam = null;

  try{
myDate = (new 
SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
   dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
  } catch(Exception e){
getLogger().error("XSP date error: ", e);
  }
   

dateParam




Bye
Judith

> -Ursprüngliche Nachricht-
> Von:  Scherler, Thorsten [SMTP:[EMAIL PROTECTED]]
> Gesendet am:  Freitag, 31. Januar 2003 18:01
> An:   [EMAIL PROTECTED]
> Betreff:  AW: AW: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?
> 
> I correct it and now:
> 
> description org.apache.cocoon.ProcessingException: Language Exception: 
>org.apache.cocoon.components.language.LanguageException: Error compiling 
>IDC2_info_int_xsp: Line 286, column -1: incompatible types Line 309, column 48: 
>variable dateParam not found in class org.apache.cocoon.www.logic.IDC2_info_int_xsp 
>Line 0, column 0: 2 errors 
> 
> the xsp:
> http://apache.org/xsp"; 
>xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
>xmlns:xsp-request="http://apache.org/xsp/request/2.0";>
>   
>   
>   Date myDate = "";
>   try{
> myDate = (new SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
> String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
>   }catch(Exception e){
> getLogger().error("XSP date error: ", e);
> }
>
>   
>   dateParam
>           
>   
> 
> 
> the request: ?date=31.01.2003
> 
> -Ursprüngliche Nachricht-
> Von: Andrew Timberlake [mailto:[EMAIL PROTECTED]]
> Gesendet: Freitag, 31. Januar 2003 17:49
> An: [EMAIL PROTECTED]
> Betreff: Re: AW: AW: AW: AW: AW: AW: xsp-element equivalent to
> xsl:param?
> 
> 
> On Fri, 2003-01-31 at 18:37, Scherler, Thorsten wrote:
> > Hello again,
> > 
> > I have shorten the xsp:
> > http://apache.org/xsp"; 
>xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
>xmlns:xsp-request="http://apache.org/xsp/request/2.0";>
> > 
> > 
> > Date myDate = "";
> > try{
> > myDate = (new
> > SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
>  ---^
> You had a missing ')'
> 
> > String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
> >   }catch(Exception e){
> > getLogger().error("XSP date error: ", e);
> > }
> > 
> > 
> > myDate 
> > 
> > 
> > 
> > 
> 
> -- 
> 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]>
> 

-
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]>




AW: AW: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

2003-01-31 Thread Scherler, Thorsten
I correct it and now:

description org.apache.cocoon.ProcessingException: Language Exception: 
org.apache.cocoon.components.language.LanguageException: Error compiling 
IDC2_info_int_xsp: Line 286, column -1: incompatible types Line 309, column 48: 
variable dateParam not found in class org.apache.cocoon.www.logic.IDC2_info_int_xsp 
Line 0, column 0: 2 errors 

the xsp:
http://apache.org/xsp"; 
xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
xmlns:xsp-request="http://apache.org/xsp/request/2.0";>


  Date myDate = "";
  try{
myDate = (new SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
  }catch(Exception e){
getLogger().error("XSP date error: ", e);
}
   

dateParam




the request: ?date=31.01.2003

-Ursprüngliche Nachricht-
Von: Andrew Timberlake [mailto:[EMAIL PROTECTED]]
Gesendet: Freitag, 31. Januar 2003 17:49
An: [EMAIL PROTECTED]
Betreff: Re: AW: AW: AW: AW: AW: AW: xsp-element equivalent to
xsl:param?


On Fri, 2003-01-31 at 18:37, Scherler, Thorsten wrote:
> Hello again,
> 
> I have shorten the xsp:
> http://apache.org/xsp"; 
>xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
>xmlns:xsp-request="http://apache.org/xsp/request/2.0";>
> 
> 
> Date myDate = "";
> try{
> myDate = (new
> SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
 ---^
You had a missing ')'

> String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
>   }catch(Exception e){
> getLogger().error("XSP date error: ", e);
> }
> 
> 
> myDate 
> 
> 
> 
> 

-- 
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]>




Re: AW: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

2003-01-31 Thread Andrew Timberlake
On Fri, 2003-01-31 at 18:37, Scherler, Thorsten wrote:
> Hello again,
> 
> I have shorten the xsp:
> http://apache.org/xsp"; 
>xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
>xmlns:xsp-request="http://apache.org/xsp/request/2.0";>
> 
> 
> Date myDate = "";
> try{
> myDate = (new
> SimpleDateFormat("dd.MM.")).parse(request.getParameter("date"));
 ---^
You had a missing ')'

> String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
>   }catch(Exception e){
> getLogger().error("XSP date error: ", e);
> }
> 
> 
> myDate 
> 
> 
> 
> 

-- 
Andrew Timberlake <[EMAIL PROTECTED]>


-
Please check that your question  has not already been answered in the
FAQ before posting. 

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




AW: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

2003-01-31 Thread Scherler, Thorsten
Hello again,

I have shorten the xsp:
http://apache.org/xsp"; 
xmlns:esql="http://apache.org/cocoon/SQL/v2"; 
xmlns:xsp-request="http://apache.org/xsp/request/2.0";>


Date myDate = "";
try{
myDate = (new
SimpleDateFormat("dd.MM.").parse(request.getParameter("date"));
String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
  }catch(Exception e){
getLogger().error("XSP date error: ", e);
}


myDate 




error (cocoon):
description org.apache.cocoon.ProcessingException: Language Exception: 
org.apache.cocoon.components.language.LanguageException: Error compiling 
IDC2_info_int_xsp: Line 289, column 66: ')' expected Line 286, column -1: incompatible 
types Line 0, column 0: 2 errors 

IDC2_info_int_xsp.java:

this.characters("\n\t\t");
string myDate = "";
try{
myDate = (new
SimpleDateFormat("dd.MM.").parse(request.getParameter("date"));
  }catch(Exception e){
getLogger().error("XSP date error: ", e);
}

The Line 289, column 66 is (*): parse(request.getParameter("date")(*))

The sitemap.log and error.log don't have the "XSP date error".


-----Ursprüngliche Nachricht-
Von: Andrew Timberlake [mailto:[EMAIL PROTECTED]]
Gesendet: Freitag, 31. Januar 2003 17:08
An: [EMAIL PROTECTED]
Betreff: Re: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?


On Fri, 2003-01-31 at 17:59, Scherler, Thorsten wrote:
> 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?
I think what you are trying to do is the following:
Date myDate = (new
SimpleDateFormat("dd.MM.").parse(request.getParameter("date"));
String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
That will receive the date in format 30.01.2003 and convert it to
01/30/2003

I'm not sure if you've understood the  concept fully.
Using the esql parameter will result in java code that looks something
like the following:

...
PreparedStatement statement = conn.prepareStatement("select * from table
where datecolumn = ?");
statement.setDate(1, myDate);
...

When using code like this, you don't have to worry about the format the
database engine uses, you only have to worry about the format the user
uses and parse that into a Date object.

I do realise that I may not always understand exactly what you are
asking so please keep asking until we fully understand each other.

-- 
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]>




Re: AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

2003-01-31 Thread Andrew Timberlake
On Fri, 2003-01-31 at 17:59, Scherler, Thorsten wrote:
> 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?
I think what you are trying to do is the following:
Date myDate = (new
SimpleDateFormat("dd.MM.").parse(request.getParameter("date"));
String dateParam = (new SimpleDateFormat("MM/dd/")).format(myDate);
That will receive the date in format 30.01.2003 and convert it to
01/30/2003

I'm not sure if you've understood the  concept fully.
Using the esql parameter will result in java code that looks something
like the following:

...
PreparedStatement statement = conn.prepareStatement("select * from table
where datecolumn = ?");
statement.setDate(1, myDate);
...

When using code like this, you don't have to worry about the format the
database engine uses, you only have to worry about the format the user
uses and parse that into a Date object.

I do realise that I may not always understand exactly what you are
asking so please keep asking until we fully understand each other.

-- 
Andrew Timberlake <[EMAIL PROTECTED]>


-
Please check that your question  has not already been answered in the
FAQ before posting. 

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




AW: AW: AW: AW: AW: xsp-element equivalent to xsl:param?

2003-01-31 Thread Scherler, Thorsten
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/")).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  tag comes in handy. Instead of
using the #Formated dat string# format you can pass the date object
directly to the esql parameter:

myDate

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.
> 
> ...
> 
>
>   String timeOfDay = "";
>   try{
>  timeOfDay = (new
> SimpleDateFormat("MM/dd/")).format(request.getParameter("date"));
>   }catch(Exception e){
> getLogger().error("XSP date error: ", e);
> }
>
>
> 
> 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  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
> > 
> > ...
> > 
> >
> >   String timeOfDay = "";
> >   try{
> >  timeOfDay = (new
> > SimpleDateFormat("MM/dd/")).format(request.getParameter("date"));
> >   }catch(Exception e){}
> >
> >
> > 
> > IDC2_int
> > 
> > 
> > select * from info_bericht  where country =' > name="GETcountry"/>'   AND  Info_datum =
> > #timeOfDay#
> > 
> > 
> > I will mention again that you should look into using 
> > tags.
> > 
> > Andrew
> > 
> > On Fri, 2003-01-31 at 16:46, Scherler, Thorsten wrote:
> > > Hello Andrew,
> > > 
> > > my final xsp should look like this:
> > > ...
> > > 
> > >   
> > >  try{
> > >  String timeOfDay = (new
> > > SimpleDateFormat("MM/dd/")).format(request.getParameter("date"));
> > > }catch(Exception e){}
> > >  
> > > 
> > > IDC2_int
> > > 
> > > 
> > >  select * from info_bericht  where country ='name="GETcountry"/>'   AND  Info_datum = #timeOfDay#
> > >  
> > > ...
> > > 
> > > 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.contentH