Redirect to another site using POST method with parameters in Stripes

kaushik picture kaushik · Aug 11, 2011 · Viewed 7.9k times · Source

Usually we can redirect to another page using ForwardResolution(path) in stripes, but I want to redirect to another 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 ?

Answer

Will Hartung picture Will Hartung · Aug 11, 2011

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.