It's not a secret anymore!
The moose likes Struts and the fly likes Posting a form to an external site Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Posting a form to an external site" Watch "Posting a form to an external site" New topic

Posting a form to an external site

Andrew McLaren
Ranch Hand

Joined: May 27, 2005
Posts: 33
Let me see if I can explain this, so that it makes sense.

I have a fairly simple Struts based app that allows a user to populate a form. I want to post that form to an external site, not one within this web application. In the forward for my action, I can't use a redirect, because that results in the request containing the form data being destroyed. But if I don't redirect, I get a 404 Page not found error when it tries to forward to the external URL.

Am I missing something simple here?

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It's certainly possible to have a form generated by your application server that posts to another site. Unless there's some processing you have to do before posting to the external site, I wouldn't bother with an Action. Just have your form post directly to the external site. Here are a few suggestions:

1-You don't use <html:form> just use <form>

2-The action="" must specify a full URL including the http:// (e.g.

3-Remember that there is no request object being passed to the external site, so all the information has to be in input fields on the form, either visible or invisible.
[ February 04, 2006: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
Andrew McLaren
Ranch Hand

Joined: May 27, 2005
Posts: 33
Ok, thanks for the reply.

Yes, it works fine with a plain old HTML form. Our architecture folks may have some issues with doing it that way, but at this point it doesn't look like there is much alternative.

Have you checked out Aspose?
subject: Posting a form to an external site
jQuery in Action, 3rd edition