<p>Does anybody know how to retrieve information from !_NEWLINE_!<p>site that assign sessionId after you logged in?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Serge_Y
Posted On:   Tuesday, September 4, 2001 07:24 PM

I have to connect to website from my java program and read from it. Sound regular but… all regular steps doesn't work here 1. url.openConnection() 2. because of POST method ( login page has post) setDoOutput(true); setDoInput(true); setAllowUserInteraction(false); 3. Prepare OutputStreamWriter and writing to server osw.write( query) . Query contains param=value&param=value…. 4. getInputStream and after reading line by line … 5. And after that I parse or whatever…. That what I did before and it worked. But now I am trying to do the same to website that assign "session Id" as soon as I   More>>

I have to connect to website from my java program and read from it.

Sound regular but… all regular steps doesn't work here

1. url.openConnection()

2. because of POST method ( login page has post)

setDoOutput(true); setDoInput(true); setAllowUserInteraction(false);

3. Prepare OutputStreamWriter and writing to server

osw.write( query) . Query contains param=value&param=value….

4. getInputStream and after reading line by line …

5. And after that I parse or whatever….


That what I did before and it worked. But now I am trying to do the same to website that
assign "session Id" as soon as I logged in. So I can't send whole Query to last servlet
because I don't know the "sessionId" and as much I know can not read "first" response get "sessionId" and write next query to server (POST will not support it).

What should I do?
Thank you .

   <<Less

Re: <p>Does anybody know how to retrieve information from !_NEWLINE_!<p>site that assign sessionId after you logged in?

Posted By:   Christopher_Pickslay  
Posted On:   Tuesday, September 11, 2001 11:09 PM

I'm not sure from your description exactly what is happening, but it sounds like you're POSTing to one URL, including your username/password, and the server is sending you back a redirect to the page, including the sessionId.

If you were making several requests, I'd parse the Location response header to get the sessionId and create a new HttpURLConnection for each request, adding the sessionId to the URL.

But it sounds more like you're just trying to execute a single request, in which case you should just be able to set your HttpURLConnection to follow redirects using setFollowRedirects(true). Then when the server returns a redirect to the URL with the sessionId included, your HttpURLConnection will automatically follow it, and you won't have to create a new, separate connection.

About | Sitemap | Contact