Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Http Status Code

843790Aug 28 2010 — edited Aug 29 2010
Hello,

I wanna make a Login on a web page, but get this error code.
import java.io.IOException;

import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;

public class Test{

	private static final String LOGIN_PAGE = "...";

	public static void main(String[] args) throws HttpException, IOException {

		HttpClient client = new HttpClient();
		GetMethod getMethod= new GetMethod(LOGIN_PAGE);

		vLoginPage.getParams().setCookiePolicy(
				CookiePolicy.BROWSER_COMPATIBILITY);
		client.executeMethod(getMethod);

		vLoginPage.setFollowRedirects(false);

		PostMethod postMethod1 = new PostMethod(
				"...");
		postMethod1.addParameter("username", "...");
		postMethod1.addParameter("passwd", "..");
		postMethod1.addParameter("target","..");

		client.executeMethod(postMethod1);

		System.out.println(postMethod1.getStatusCode());

		String redirectLocation = null;
		Header locationHeader = postMethod1.getResponseHeader("location");
		if (locationHeader != null) {
			redirectLocation = locationHeader.getValue();
			System.out.println(redirectLocation);
		} else {
			// The response is invalid and did not provide the new location for
			// the resource. Report an error or possibly handle the response
			// like a 404 Not Found error.
		}
		//

	}
}
Does anyone hava an idea how to solve this problem?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 26 2010
Added on Aug 28 2010
4 comments
213 views