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 Struts forward to url outside current webapp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts forward to url outside current webapp" Watch "Struts forward to url outside current webapp" New topic
Author

Struts forward to url outside current webapp

chris gar
Ranch Hand

Joined: Jul 20, 2002
Posts: 45
I read this post but I don't think it is correct:
http://www.coderanch.com/t/46457/Struts/forwarding-URL-outside-web-application

I have 2 web apps running in the same JBoss server (myApp and myAppReports).

In the struts config of myApp, I want to be able to forward requests to the myAppReports servlet. (ex. a user clicks the button to generate a report - presto - he is forwarded to the reports servlet with req parameters to run report)

I'm unable to forward to a URL like http://localhost/myAppReports because stuts appears to force forward to be within the same app as that of the struts-config. ( I get errors like struts forwards must begin with a /)

Is there a way for me to do this?

Thanks.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The thread you refer to is correct, except it leaves out one very important deatil: You must specify redirect="true" in your forward definition in order to forward to a URL outside of your current application. One restriction of this method, though, is that you obviously can't pass objects in either the request or the session because the other application has no visibility to your application's request or session object. All the information you pass must be in the form of parameters passed in the query string (?parm1=xx&parm2=yy, etc).
[ May 03, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
chris gar
Ranch Hand

Joined: Jul 20, 2002
Posts: 45


Indeed! Works like a charm.

However - the myAppReports did not see the request parameters ?? hmm.

Anyway, I wrote a little code to get the paramters before getting the forward, then appending again

like this:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts forward to url outside current webapp