By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,557 Members | 1,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,557 IT Pros & Developers. It's quick & easy.

Problems with HttpURLConnection

P: n/a
I have a class that opens up an HttpsURLConnection to a web server.
The purpose is to log in to the web resource using Siteminder forms
based authentication. Therefore, the request is a POST, and the body
of the request is the username, password and target. The object is to
get the cookie for the siteminder session to use on subsequent
requests. Here is the skeleton code:

URL url = new URL("https://foo.com/login");
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
uc.setRequestMethod("POST");
uc.setDoOutput(true);
String requestBody = "USER=XXXX&PASSWORD=XXXX&target=XXXX";
uc.connect();
OutputStream os = uc.getOutputStream();
os.write(requestBody.getBytes());
setCookieValue(uc.getHeaderField("Set-Cookie"));

In JDK 1.3, the webserver processes the request then uc.getContent()
returns the results of the login and uc.getHeaderField("Set-Cookie")
gives me the session cookie I need.

However, in JDK 1.4.2, uc.getContent() is just giving me the login
page itself and no cookie value, as if the webserver is not processing
the user parameters.

What would change between these versions of the JDK?

Thanks,

-Art Perry
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.