This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line!
See this thread for details.
Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Forward to Another WebApp using RequestDispatcher

 
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.
 
Marshal
Posts: 67496
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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,
 
Ranch Hand
Posts: 3851
  • 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
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic