dcsimg
I'm trying to write a program in java that will log onto this page: (http://infotrac.galegroup.com/itweb/uwcn).
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Lee_Jones
Posted On:   Saturday, February 1, 2003 03:06 AM

I'm trying to write a program in java that will log onto this page: (http://infotrac.galegroup.com/itweb/uwcn). However, the cookies on this page are proving an impossible task to handle. When I go there in my browser, it sets an intial cookie (alteonP=blahblah) and then two further cookies (Ctemp & Cperm). However, when I connect to the URL using an httpURLConnection object as follows: URL url = new URL("http://infotrac.galegroup.com/itweb/uwcn"); HttpURLConnection http = (HttpURLConnection) url.openConnection(); String cookie=http.getHeaderField("Set-Cookie"); System.out.print(cookie); I get no cookies sent by the serve   More>>

I'm trying to write a program in java that will log onto this page: (http://infotrac.galegroup.com/itweb/uwcn). However, the cookies on this page are proving an impossible task to handle. When I go there in my browser, it sets an intial cookie (alteonP=blahblah) and then two further cookies (Ctemp & Cperm).

However, when I connect to the URL using an httpURLConnection object as follows:



URL url = new URL("http://infotrac.galegroup.com/itweb/uwcn");

HttpURLConnection http = (HttpURLConnection) url.openConnection();

String cookie=http.getHeaderField("Set-Cookie");

System.out.print(cookie);



I get no cookies sent by the server? the program returns null! I've tried turning off redirection, but the response code is always 200 OK, which means its not trying to redirect me is it?

If I create an input stream from the above connection and output the HTTP Body returned by the server on the above request, I get the error message:

We are unable to recognize you as having access to this Gale Group Product



The best information we have about this problem is:
Temporary cookie support must be enabled in your browser in order to use this product.

So somehow I am missing the cookie!?!?!

I've tried printing out the entire header returned by the server, which returns the following every time:


null HTTP/1.1 200 OK

Date Wed, 29 Jan 2003 12:17:56 GMT

Content-Type text/html

Connection close

Server Netscape-Enterprise/3.6 SP1

Via 1.1 webcacheH10 (NetCache NetApp/5.3.1R2)



And there is no sign of anything that resembles a cookie or any other identifiable information, so can anyone help me understand where I am missing the cookie support? I've tried turning off redirection and cacheing, tried connecting and reconnecting and also tried changing the user agent, but nothing makes a blind bit of difference!

I ultimately want to log onto the site, which requires passing the connection to the following URL http://infotrac.galegroup.com/itweb/uwcn?id=100117976 but seeing as I can't even get the site to send me a cookie, I'm a long way from achieving this I think :( I'm beginning to think the HttpURLConnection object isn't the way to go about this, given the grief its caused, but it *must* be possible mustn't it?



So, if anyone can offer some support on the above, it would really be appreciated.    <<Less

Re: I'm trying to write a program in java that will log onto this page: (http://infotrac.galegroup.com/itweb/uwcn).

Posted By:   Ben_Clarke  
Posted On:   Sunday, February 16, 2003 09:38 AM

In order to support cookies, I had to use the Apache Jakarta project's httpclient package. It's completely taken care of for you and supports SSL as well. It's at



http://jakarta.apache.org/commons/httpclient/index.html

and it makes client-side HTTP anything much easier.



HTH

Re: I'm trying to write a program in java that will log onto this page: (http://infotrac.galegroup.com/itweb/uwcn).

Posted By:   Christopher_Koenigsberg  
Posted On:   Monday, February 3, 2003 06:43 AM

Maybe they are looking for something in some other header that you need to set before you make the connection request, e.g. the user agent, referrer, etc.?

About | Sitemap | Contact