• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Access a resource in different context

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://coderanch.com/t/364150/Servlets/java/forward-different-context
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks ben,

Am able to invoke resource in another app.

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

Regards, Raghav
 
What's that smell? I think this tiny ad may have stepped in something.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic