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 Date format problem when using URLConnection to a JSP (JSTL 1.1) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Date format problem when using URLConnection to a JSP (JSTL 1.1)" Watch "Date format problem when using URLConnection to a JSP (JSTL 1.1)" New topic
Author

Date format problem when using URLConnection to a JSP (JSTL 1.1)

Helen Shen
Greenhorn

Joined: Sep 20, 2006
Posts: 5
I have a very simple JSP with only one liner in the body


Opening the page in the browser, I see the expected result - 08/20/08

However, when I use URLConnection to connect to the same JSP, somehow the formatting is lost. The URLConnection's getInputStream gave me the date in
"Wed Aug 20 16:15:35 EDT 2008" format.

Any idea?
[ August 20, 2008: Message edited by: Helen Shen ]
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

<sorry double post>
[ August 20, 2008: Message edited by: Steve Luke ]

Steve
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Can you give us the code you are using on the URLConnection to get the value returned from the server?
Helen Shen
Greenhorn

Joined: Sep 20, 2006
Posts: 5
JSP on the server:



URLConnection Code:




Result:


[ August 20, 2008: Message edited by: Helen Shen ]
Helen Shen
Greenhorn

Joined: Sep 20, 2006
Posts: 5
I am not sure why, but adding this line of code solved the problem!!!


My thought was that no matter what the user-agent is, the output html should be the same...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date format problem when using URLConnection to a JSP (JSTL 1.1)