aspose file tools*
The moose likes Servlets and the fly likes Forward to Another WebApp using RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Forward to Another WebApp using RequestDispatcher" Watch "Forward to Another WebApp using RequestDispatcher" New topic
Author

Forward to Another WebApp using RequestDispatcher

Philip Plenckers
Greenhorn

Joined: Jul 25, 2006
Posts: 18
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.


Philip
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Sorry, not possible. You'll need to redirect.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Philip Plenckers
Greenhorn

Joined: Jul 25, 2006
Posts: 18
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

Joined: Oct 11, 2004
Posts: 3830
... 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

Joined: Jul 25, 2006
Posts: 18
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Forward to Another WebApp using RequestDispatcher