Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

dates and times as integers in a query string  RSS feed

 
Kirk Martin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to insert dates and times into a database. The dates are displayed from the database as for example

March 1, 2005 - but in the database the id is 1
April 1, 2005 - and for April the id is 2

I want the users to see March 1, 2005 which I do now but need to pass 1 to the query string and 2 etc. How can I change the dates in the background using JSP to the Integer of 1 for March and 2 for April or for that matter whatever date the user clicks on? My servlet needs to see the dates and times as an integer or it wont work.

Any help would be appreciated.
[ December 04, 2004: Message edited by: Kirk Martin ]
 
Logan Owen
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not completely clear on what you are wanting, but my suggestion would to use a if else statement (actually, a switch statement, but I don't remember the exact syntax). Pull out the month, and try something like this:



so on and so forth. Also, it is best to put logic code in a class outside of the JSP and call it from the JSP. And always remember to include a default case, just in case something breaks down, the whole application will not fail.
 
Kirk Martin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What i'm wanting is to pass 1 or 2 or 3 or 4 etc. (these are the dateID numbers in the database) depending on what date the user clicks on in the form. So for example if you (Logan Owen) clicks on April 1, 2005 in the query string it will be number 2 instead of April, 1 2005. The reason is because in my servlet (I'm using switch and a case to do the processing) I have for the dates - ds.setDateID(Integer.parseInt(request.getParameter("dateID")));

If you have any questions or a solution let me know.

Thanks

Kirk
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kirk,
You can set the value in your JSP. For example,
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our JSP forum as this is more about JSP than JDBC.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!