This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 4164
    
  21

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

Steve
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4164
    
  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...
 
jQuery in Action, 2nd edition
 
subject: Date format problem when using URLConnection to a JSP (JSTL 1.1)
 
Similar Threads
Populating select box with dates
Java Date formatting problem
timestamp display problem
Oracle java date problems
How to Convert DTD file into XFLAT file