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.