File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access a resource in different context

 
KRK Gowda
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Please tell me a solution for this.


Thanks and Regards,
 
ankur rathi
Ranch Hand
Posts: 3830
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Raghavendra Nittur
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Regards, Raghav
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this thread is now about configuring Tomcat, moving to the Apache / Tomcat forum.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raghavendra Nittur
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ben,

Am able to invoke resource in another app.

corssContext is Working......!!!

Regards, Raghav
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic