Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts forward to url outside current webapp

 
chris gar
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
chris gar
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic