It's not a secret anymore!*
The moose likes Servlets and the fly likes Accessing a URI from a program and checking cookies enabled Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Accessing a URI from a program and checking cookies enabled" Watch "Accessing a URI from a program and checking cookies enabled" New topic
Author

Accessing a URI from a program and checking cookies enabled

SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
I have a simple program that submits a POST request to a web site. The page being accessed is a LogIn page. I have configured the request from my program to set all the request parameters and HTTP headers that would be set if the user was using a regular browser in order to fool the web site into thinking the request originated from a browser. When the request is made, the web site responds with content which, after dumping to a flat file, produces a page which instucts the user that their browser must be set to accept cookies.
I can't understand how the web site determined that I did not have cookies enabled. From the servers perspective, you need at least 1 1/2 rounds trip requests in order to determine if the browser has cookies enabled. In the first reponse, the web site will send a "Set-Cookie" header containing a sessions id which instructs the browser to resend this header for all subsequest requests. But in my case, I never see the "Set-Cookie" header, not even in the first response. I'm definitely looking for it, but I never see it.
The server must have a method for determining if cookies are enabled or not, even before the first response if committed, but there must be a way to fool the server.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
I have used the HttpClient toolkit to be found here. Frank would suggest the HttpUnit toolkit at sourceforge.
Both provide for full emulation of cookies, etc.
Bill
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
Thanks! This is great info!
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
Hi William,
I downloaded the HttpClient toolkit from Jakarta and installed it. I ran my test using a sample program from the Jakarta site and I still get the same response as I did when I submitted the request from my own custom program. I still get the HTML screen indicating that cookies are not enabled on the first request. Weird.
Which type of CookiePolicy do you use? I tried them all.
Thanks
 
wood burning stoves
 
subject: Accessing a URI from a program and checking cookies enabled
 
Similar Threads
crawler
cookie explanation
Cookie Problem
session & cookie
Issues with sending cookies to server