Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forward to Another WebApp using RequestDispatcher

 
Philip Plenckers
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, not possible. You'll need to redirect.
 
Philip Plenckers
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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,
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic