开发者

Adding post parameters to request before making the request go somewhere else in Java

In a JSP page, I need to do the following (this is psuedo-code):

//Attach new POST params to request
//Make the request go to a 3rd party URL

How do I do this?

The way we are solving this right now (is terrible):

//populate and generate an HTML form
//on window.load submit the HTML form (as a POST) to a 3rd party URL

We want all this to be done on the server side instead of开发者_JAVA百科 having this JS hack


You can use URLConnection to make POST request, here is an example


There are many ways to send a HTTP POST. I recommend a use of apache HttpClient library.

Here is the previous question and answers on Stack Overflow. The question was for Andriod but should work perfectly with Java.

Another method is to use URLConnection class. There was an answer posted by me on that question.


There is no way to do this in Java. You would need some sort of proxy server or apache re-write rule or something like that. Java is not the right place to do this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜