Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Helen Shen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<sorry double post>
[ August 20, 2008: Message edited by: Steve Luke ]
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you give us the code you are using on the URLConnection to get the value returned from the server?
 
Helen Shen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP on the server:



URLConnection Code:




Result:


[ August 20, 2008: Message edited by: Helen Shen ]
 
Helen Shen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic