• Post Reply Bookmark Topic Watch Topic
  • New Topic

Howd do you read a webpage that requires a cookie?

 
Chaz Andrews
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to download the source code of a web page. I know how to do this. But if I want to access a webpage that requires a cookie I dont know what to do. Can anyone help me?
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chaz

Try this google results,

http://www.google.com/search?hl=en&lr=&safe=off&client=safari&rls=en&q=java+setrequestproperty+urlconnection+cookie&btnG=Search

Basically you need to understand Http protocol upto some level and then use the setRequestProperty() method on the connection object you might have.

Also this link for the Cookie RFC will help to understand how cookies are passed between the server and the browser.

http://www.faqs.org/rfcs/rfc2965.html

Regards
Maulin
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Jakarta Commons HttpClient library supports cookies, and is easy to use for client-side HTTP operations.
 
Chaz Andrews
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys
 
Norm Radder
Bartender
Posts: 1526
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A problem might be getting the correct value for the cookie.
How do you do that? Can you get it from the browser's cache?
A technique I've used is to have a proxy server that displays all its traffic. Set your browser to go thru the proxy server and you can see what goes on between the browser and server.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!