• 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

Forward to Another WebApp using RequestDispatcher

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I was wondering whether it is possible to forward a request to another web application residing on a completely different Web Application Server.

My code always returns null for the servletContext I try to get:
Servlet in application A:

try {

// code that throws NotAuthorizedException

} catch (NotAuthorizedException e) {
// forward to not authorized page
ServletContext sc = this.getServletContext().getContext("/Intranet/notAuthorized.html");

//sc == null by here

sc.getRequestDispatcher("/Intranet/notAuthorized.html");


e.printStackTrace();
}


Please note that the getContext() method requires a URI. But how the heck does it find the html page page in the Intranet application. I'm confused here except when it's just not possible this way,

thanx,

Philip.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, not possible. You'll need to redirect.
 
Philip Plenckers
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks

not the answer I hoped for, but the one I expected. Redirect it will be.

thanks again for looking in to it,
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
... or may be you can override forward() method (create your own implementation) that will have such facilitiy... probably you will have to write your own container and that will not follow Sun specification...
 
Philip Plenckers
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

it might be an idea I can use later. However, at this point the redirect seems to do the job ok. I expected some problems with the browser back button but at this point it doesn't seem to be a problem. So for now I'm quite happy
 
reply
    Bookmark Topic Watch Topic
  • New Topic