File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Posting a form to an external site" Watch "Posting a form to an external site" New topic
Author

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?

Thanks
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. http://www.yahoo.com).

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 ]

Merrill
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.

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Posting a form to an external site