File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Timestamp issue with %20 space. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Timestamp issue with %20 space." Watch "Timestamp issue with %20 space." New topic
Author

Timestamp issue with %20 space.

Frederik Ericsson
Ranch Hand

Joined: Apr 27, 2005
Posts: 128
Hello Friends

I am trying to retrieve the timstamp of certain set of records and display in a jsp. here it diplays the timestamp like this 2007-06-16 19:16:57.798.

from this jsp I have to select one record based on timestamp and send it as a input to the next page to retrive some more fields. the problem is, while sending this time stamp as a url parameter it passes the time as
2007-06-16%2019:16:57.798, the space between the date and time is replaced with %20, I want to get rid off this issue, can you please tel me how to send the timestamp to the next page with this %20.

I badly need your help guys.
N D Fisher
Greenhorn

Joined: Jun 01, 2007
Posts: 27
Why not just replace the %20 with spaces after you've retrieved the passed parameter on your second JSP page?

Something like:

<%
String dateParam = request.getParameter("dateTime");

String formattedString = dateParam.replaceALL("%20"," ");
%>


At least, that's how I'd fix it myself anyways.


Nick
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

Originally posted by N D Fisher:
Why not just replace the %20 with spaces after you've retrieved the passed parameter on your second JSP page?


Not necessary. The decoding should be automatic.

Is this a real problem, or only one you think is a problem because you see %20 on the URL? When the parameter is retrieved, the URL decoding should be automatic.

If it is a real problem, how are you obtaining the parameter value on the target page?
[ June 20, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
N D Fisher
Greenhorn

Joined: Jun 01, 2007
Posts: 27
Originally posted by Bear Bibeault:


Not necessary. The decoding should be automatic.


OK, no probs. I was presuming the characters were still there when he retrieved the string........


Nick
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

Originally posted by N D Fisher:
I was presuming the characters were still there when he retrieved the string


Even if that is the case, the correct approach is to find out why the automatic decode isn't working as expected rather than putting work-around code on the page.
Frederik Ericsson
Ranch Hand

Joined: Apr 27, 2005
Posts: 128
Thanks N D Fisher & Bear Bibeault,

Actually I got the timestamp with %20 from the URL, I have to use this timestamp to retrieve the record from DB. automatic decode is not working, actually I have to compare this timestamp with the timestamps in DB, if i do it as it comes from URL it says no records found. if I do some work around its working... please let me know the proper way of doing...

can you please fix my issue...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

Originally posted by Frederik Ericsson:
Actually I got the timestamp with %20 from the URL


I ask again: how?
Frederik Ericsson
Ranch Hand

Joined: Apr 27, 2005
Posts: 128
while am using getParameter(timestamp), it rerutns
2007-06-16%2019:16:57.798 while send this param to pull the record from DB.. there the issue goes...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

Originally posted by Frederik Ericsson:
while am using getParameter(timestamp)


getParameter() will decode the URL parameters. So the the only way that the %20 can "survive" this decoding process is if it has been doubly-encoded in the first place.

So now the question becomes, how are you creating the URL and what does it look like when you use it?
Frederik Ericsson
Ranch Hand

Joined: Apr 27, 2005
Posts: 128
http://***.***.com:8080/****/***.jsp?appid=****×tamp=2007-06-18%2015:31:32.747
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

OK, that looks correct. But when I plug a URL with that same query string into my own test page, the %20 is decoded to a space as expected.

Are you sure that's the exact URL? Can you show us the actual code that's fetching the value?
Frederik Ericsson
Ranch Hand

Joined: Apr 27, 2005
Posts: 128
timestamp=document.Display.record[count].value

document.DisplayRecords.action=****/***********.jsp?timestamp="+timestamp;
document.DisplayRecords.submit();
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

Hmmm, while I'm not sure that it's the cause of your problem, putting a query string onto your form action is definitely a poor practice.

Rather, make timestamp a hidden element in your form.
 
jQuery in Action, 2nd edition
 
subject: Timestamp issue with %20 space.