Placing the Cookie in the HTTP header works for me.

        URL servlet = null;
        URLConnection conn = null;
        String encodedParams = "";
        try {
            servlet = new URL(servletURL + "/" + servletName);
        }
        catch (MalformedURLException e) {
            throw new IOException(e.getMessage());
        }
        if (params != null)
            encodedParams = encodeParameters(params);
        conn = servlet.openConnection();
        conn.setDoInput(true);
        conn.setDoOutput(true);
        conn.setUseCaches(false);
        conn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
        conn.setRequestProperty("Cookie: ",cookies);


Graeme Wallace wrote:

> Hi,
>
> I got the HTMLPost.java file, thanks for that.
> Now I've got a new problem with posting data from a Java application.
>
> How do you go about sending a cookie in the request as well as post
> variables ?
>
> Basically I want the server to generate a cookie and the client to always
> send it back for identification purposes. So when I receive a cookie
> i store it internally withing my application. Then when I want to send
> some new data to the server I encode up the cookie and post variables.
>
> Unfortunately outputing the "Cookie: <name>=<value> ;" stuff doesnt work as
> the post variables are ignored at the server end.
>
> Any ideas ?
>
> Graeme Wallace
> Technical Director
> Interactive Network Technologies
> 2901 Wilcrest Drive, #100
> Houston
> Texas, 77042
>
> Tel: 1 713 975 7434
> Fax: 1 713 975 1120
> Email: [EMAIL PROTECTED]
> WWW: http://www.int.com
>
> -- --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> READ THE FAQ!!!!     <http://java.apache.org/faq/>
> Archives and Other:  <http://java.apache.org/main/mail.html/>
> Problems?:           [EMAIL PROTECTED]

--
Gregory Krasnow
Senior Software Engineer
Stone Analytics, Inc.
ph: (619)503-7540 x204
fax: (619)503-7541
email: [EMAIL PROTECTED]




-- --------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
READ THE FAQ!!!!     <http://java.apache.org/faq/>
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to