This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi all, I have 2 contexts. in one context, i am uploading a file. In other context, i have written a servlet to access uploaded file and download it to local machine. But i am stuck at how to access resource in different context but on same application server.
It seems, from what you've written, that these two servlets should be in the same context.
That being said Servlet.getServletContext(contextName) can get you access to another context within the same server. The spec does not go into a lot of detail on the subject of cross context interaction so I would expect inconsistent behavior among different containers. Tomcat, for instance disables this, by default. To enable this capability, see the crossContext attribute on this page: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
Originally posted by Ben Souther: Servlet.getServletContext(contextName) can get you access to another context within the same server. Tomcat, for instance disables this, by default. To enable this capability, see the crossContext attribute on this page: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
Hi ben, I have gone through the link. Am unable to find the file in which i could set this attribute to true. am using tomcat 5.5.20.
There are several ways to deploy a webapp in Tomcat. The simplest is just to drop a war file or proper directory structure under the webapps directory. If you want to configure your application to use something other than the default settings, you might want to look at some of the other ways.
In older versions, you would enter a <Context ... /> node in tomcat/conf/server.xml. In newer versions, you would enter this xml node in it's own text file (context fragment file) with the name of your application + the ".xml" extension, and place it under the tomcat/conf/Catalina/localhost directory.
It is in this node that you would set the crossContext attribute.