I am trying to post few parameters to an external url while redirecting to it. I've tried httpclient methods , they post data but do not redirect to the external url. any ideas? Here's my code: try {
HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod("https://paymentsite.com/pay") {
@Override
public boolean getFollowRedirects() {
System.out.println("Overrriding the HttpClient Follow Redirect switch.");
return true;
}
};;
try {
//httpClient
postMethod.addParameter("amt","850");
postMethod.addParameter("pid","155");
httpClient.executeMethod(postMethod);
if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
//now i want the user to be redirected to the external site. with the post parameters...
} else {
}
} catch (Exception e) {
System.out.println("Exception : " + e.toString());
e.printStackTrace();
}
} catch (Exception e) {
System.out.println("exception main: " + e.toString());
e.printStackTrace();
}