dcsimg
URLConnection and POSTing with Cookies
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jeff_Owens
Posted On:   Monday, August 19, 2002 04:34 PM

I've almost got it, but just not quite. I understand how and can retrieve cookies using the getHeaderField. So there's that. The process for POSTing using URLConnection appears to be: 1. Open connection. 1. Write data. 2. Read results. Ok, so far. Now comes my serious misconception: How do I set the cookie - after I've retrieved it, and prior to posting my data? I get an exception: Illegal State Exception: Already Connected. This is when I've already got the URLConnection open and try to setRequestObject("Cookie","....") I need to integr   More>>

I've almost got it, but just not quite.



I understand how and can retrieve cookies using the getHeaderField. So there's that.



The process for POSTing using URLConnection appears to be:

1. Open connection.

1. Write data.

2. Read results.



Ok, so far.



Now comes my serious misconception:

How do I set the cookie - after I've retrieved it, and prior to posting my data?

I get an exception:

Illegal State Exception: Already Connected.

This is when I've already got the URLConnection open and try to setRequestObject("Cookie","....")




I need to integrate the 2 processes I know: 1. Getting and sending cookies, and 2. Posting data and reading results.


Thanks so much,

Jeff Owens

   <<Less

Re: URLConnection and POSTing with Cookies

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, August 20, 2002 09:21 AM

I think you are confusing the cookies in the HttpRequest that spawned "you" (the servlet) on the one hand, with any cookies in the new URL Connection you are making. The two have nothing to do with each other.

About | Sitemap | Contact