• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts forward to url outside current webapp

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read this post but I don't think it is correct:
https://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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic