You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ch...@accenture.com on 2003/11/04 10:35:03 UTC

Struts form submission using POST

How to submit a form to an external web link (not part of the current
web application)?

 

In struts action, all links are interpreted relative to web context and
therefore "forward" object specified in 

struts-config does not work.

 

e.g.

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)

{

 

            ActionForward forward =
mapping.findForward("constructionPage");

}

 

// Strtus-config:

 

<forward name="constructionPage"
path="http://www.externalformprocessor.com"/>

 

Web context:  myapplication

 

URL in <forward> tag of the struts-config is evaluated as
"/myapplication/http://www.externalformprocessor.com" which 

obviously is not a valid URL.

 

 

One approach is to append all form parameters as query string in URL and
use response.sendRedirectTo(...) method of HTTPServeletRequest class

but this is not desirable for security reasons.

 

Does any one know any alternative approach to submit forms to external
sites using POST?

 

Any suggestion will be appreciated.



This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.

RE: Struts form submission using POST

Posted by Andrew Hill <an...@gridnode.com>.
What are you actually trying to do here?
a.) Have the browser directly submit the form somewhere else
 - or -
b.) have the browser submit to *your app* first and then and forward outside
from the action?

if(a)
then your execute code is irrelevant as you wont be going through the action
on submit - What you need is to have the 'action' attribute of the pages
form tag point at the external site. (Not quite sure how you would do this
using the struts tags as Im not familiar enough with their syntax)

if(b)
You cant do this using a server side forward. It would require a client side
forward (redirect). Ive never tried this with a POST rather than a GET, but
Im assuming that since your asking about it it doesnt work?


-----Original Message-----
From: chinmay.r.parikh@accenture.com
[mailto:chinmay.r.parikh@accenture.com]
Sent: Tuesday, 4 November 2003 17:35
To: struts-user@jakarta.apache.org
Subject: Struts form submission using POST


How to submit a form to an external web link (not part of the current
web application)?



In struts action, all links are interpreted relative to web context and
therefore "forward" object specified in

struts-config does not work.



e.g.

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)

{



            ActionForward forward =
mapping.findForward("constructionPage");

}



// Strtus-config:



<forward name="constructionPage"
path="http://www.externalformprocessor.com"/>



Web context:  myapplication



URL in <forward> tag of the struts-config is evaluated as
"/myapplication/http://www.externalformprocessor.com" which

obviously is not a valid URL.





One approach is to append all form parameters as query string in URL and
use response.sendRedirectTo(...) method of HTTPServeletRequest class

but this is not desirable for security reasons.



Does any one know any alternative approach to submit forms to external
sites using POST?



Any suggestion will be appreciated.



This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information.  If you have
received it in error, please notify the sender immediately and delete the
original.  Any other use of the email by you is prohibited.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org