Redirect to an Outside application along with the hidden values
Our application uses Struts and JSF , (started using struts this week) ..I am to redirect the user to an outside application (different server anb application) with some of the hidden values ...
I was wondering what should I use in my ActionClass execute method ...
public class SendToGoAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
####################################
#########################################
}
}
Thanks for your time
// redirect to the outside application
response.sendRedirect( "http://theTargetUrl?param1=" + param1Value);
// return null from the action to indicate you have handled the response.
return null;
Ok. I see where you're coming from now.
The http redirect does not support POST - it only supports GET.
So if you use a redirect, you have to send all your parameters in the request string. With 500 parameters, that can be messy, and also might not work, as there is a limit on the url.
Alternative
- produce an HTML page, with a form, and all the values required in the hidden fields. Have a javascript onload event that submits the form to the required application.
Its kind of doing a manual redirect, but it lets you do a post, rather than get.
Another alternative would be to use java.net classes to open a connection to that remote server, and pass along the parameters. You would do that from java code. But that would still look like it was coming from your application, so it might not be applicable.
is that 500 parameters you are passing between web apps?
WHY?
<html>
<body onload="document.forms[0].submit()">
<form name="redirectForm" action="http://some.url.com" method="post">
<input type="hidden" value="<%= paramValue %>">
</form>
</html>