开发者

Redirect to another site using POST method with parameters in Stripes

Usually we can redirect to another page using ForwardResolution(path) in stripes, but I want to redirect to an开发者_如何学Cother site. So when I am using ForwardResolution it will be interpreted as

http://localhost:8080/MySiteName/<Address of the other site>

I have read this link, but how to add parameters to the address ? I want to submit variables in POST method to that site. Is it possible using an action bean in Stripes ?


Actually, you can't use a ForwardResolution to go to another site. A Forward is an internal concept within the Servlet container. What you can do is a RedirectResolution, and you can use that to send a normal GET query to another site, including query parameters.

http://example.com/action?search=thing

But, that will be a GET, not a POST.

Redirect works because it sends the URL to the browser, and the browser then resubmits it to the destination site.

The only way to send a POST is to send a populated HTML form to the browser, with the action parameter pointing to the new site and method="POST", and then use a little bit of Javascript to automatically submit the form once the page is loaded. For a small form filled with hidden fields, this is quite fast, most users won't even see it happen, but it does require javascript to be enabled in their browser.


The technologies are different, but the answer to this previous question has a good description of the overall HTTP exchange. One of the strategies mentioned in that answer is for your action to do the post to the third-party site behind the scenes and then redirect to the appropriate location. This could be done via HttpClient or HttpURLConnection instead of the .NET HttpWebRequest.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜