I am trying to redirect to a URL from a servlet using POST. I get no
error messages but my page doesn't go anywhere. My print statement at the
end prints "ResponseBody = null". What am I doing wrong? This is my code
that I have (note I have removed actual URL for security reasons)....

//Create an instance of HttpClient.
HttpClient client = new HttpClient();

// Create a method instance.
PostMethod post = new PostMethod("https://URL";);
NameValuePair[] data = {
new NameValuePair("agent_id", username),
new NameValuePair("password", pwd),
new NameValuePair("poltyp", type),
new NameValuePair("polno", policy)
};
post.setRequestBody(data);

try {
client.executeMethod(post);
post.releaseConnection();

String in =
post.getResponseBodyAsString();
System.out.println("ResponseBody = " +
in);

}
catch(HttpException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}

Thank you for your help!
Kara


This message may contain confidential or proprietary information and is
intended only for the person(s) to whom it is addressed. Any use,
distribution, copying or disclosure of confidential information by any
other person is strictly prohibited. If you have received this message in
error, please notify the e-mail sender immediately, and delete the
original message without making a copy. For information on the UW
Foundation's privacy policy, please visit:
UW Foundation Privacy Policy

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.