The Artima Developer Community
Sponsored Link

Java Answers Forum
Confusing - Cookie Handling in Java

2 replies on 1 page. Most recent reply: Jun 29, 2004 2:30 AM by Zzz

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Zzz

Posts: 4
Nickname: javanoob
Registered: Feb, 2004

Confusing - Cookie Handling in Java Posted: Jun 28, 2004 7:49 PM
Reply to this message Reply
Advertisement
i have a hard time understanding how cookies are handle using java. suppose i got a webpage, authenticate.jsp
that do this :
session.setAttribute("user", "me");
which is actually the authentication key to access
other resource of that domain and in other java program i use URLConnection to access this page
and save the header like this:

URL url = new URL("http://somedomain/authenticate.jsp");
URLConnection conn = url.openConnection();
String cookieValue = conn.getHeaderField("Set-Cookie");

i found out that the cookieValue does not contain the attribute set by authentication.jsp.
where is the attribute value actually stored to pass it back so that i can access
other resources from that domain


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Confusing - Cookie Handling in Java Posted: Jun 29, 2004 1:44 AM
Reply to this message Reply
the follwing two urls can be of help for u

http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-Cookies.html

http://www.hccp.org/java-net-cookie-how-to.html

Zzz

Posts: 4
Nickname: javanoob
Registered: Feb, 2004

Re: Confusing - Cookie Handling in Java Posted: Jun 29, 2004 2:30 AM
Reply to this message Reply
Thanks for replying! as what i had read from your first link, i find that the HttpServletResponse object actually have a getCookies() method to get the cookies set by another webserver. By any chance is there away to get the response from the HttpURlConnection/URLconnection as a HttpServletResponse Object so that i can get the cookie values?

Flat View: This topic has 2 replies on 1 page
Topic: jasperreports Previous Topic   Next Topic Topic: 'file open' request...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use