File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes URLConnection and Java HttpSession's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "URLConnection and Java HttpSession Watch "URLConnection and Java HttpSession New topic
Author

URLConnection and Java HttpSession's

Kyle Willkomm
Ranch Hand

Joined: Sep 10, 2001
Posts: 44
Is there a way to make a connection over the web to a java application that maintains a session. It seems that using the URLConnection class you must instantiate it with the URL you want to hit. In doing so each new URL you hit the server with seems to get assigned a new session id defferent from the previos. And so I can not find a way to hit the java web application with several requests in a row that are treated as coming from the same session.
anandh
Greenhorn

Joined: Sep 06, 2001
Posts: 22
I have been nagged by exactly the same question. Any inputs from gurus appreciated!
Kyle Willkomm
Ranch Hand

Joined: Sep 10, 2001
Posts: 44
I have found a solution that works for Tomcat Servlet Engine. It should work for all app servers and servlet engines that implement cookies to set their session id's. You simply parse out the cookie from your first request and submit is back with all subsequent requests. give me an e-mail and I'll send you the code. kyle.w.willkomm@accenture.com
anandh
Greenhorn

Joined: Sep 06, 2001
Posts: 22
Hey Kyle,
I just sent you an email. Hope to get a reply soon!
Thanks much.
Kyle Willkomm
Ranch Hand

Joined: Sep 10, 2001
Posts: 44
There is apparently a open source solution to this problem at the jakarta.apache.org site. The HTTPClient they have in the Jakarta Commons area contains this functionality.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLConnection and Java HttpSession's