• Post Reply Bookmark Topic Watch Topic
  • New Topic

ServletCotext.getContext(uri) !!!

 
bob dapaah
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following problem. I'm using the latest version of Tomcat 4.xx and have two contexts under the webapps directory.
I am trying dispatch a request from one context to another using the following code:

The above throws a NullPointerException as the "outsideContext" object is null! Can anyone tell me why a reference for the other context cannot be obtained?
Bob
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the Servlet docs, for the getContext() method:
"In a security conscious environment, the servlet container may return null for a given URL."
Go to $catalina_home/conf/server.xml and set your context's crossContext attribute to true if you want calls within this application to ServletContext.getContext() to successfully return a request dispatcher for other web applications running on this virtual host. See the Tomcat docs for reference.
 
bob dapaah
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
That did the trick.
Bob
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!