tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefanos Karasavvidis <>
Subject getting same context accross virtual hosts
Date Tue, 10 Jul 2001 21:11:28 GMT
I'm using tomcat 3.2.2 with several configured virtual servers in one JVM.
I want to share an object across the various virtual hosts.

I'm using for this the
in one servlet, and then I try to retrieve this object from a servlet in 
another virtual host with

well, it doesn't work, and this is because each 
getServletContext().getContext(uri) call returns a different instance of 
org.apache.tomcat.facade.ServletContextFacade depeding on the virtual 
host the sevlets are called from

for the uri, I tried several "versions", using the context name (say 
foo) like "/foo" and the virtual servers name like
"/host1/foo" and the ip address like "/ip/foo".
 For the same virtual host, all these uri return the same instance, 
except from the virtual host the attribute
was first set which returns a different instance for the uri's with the 
Across the virtual hosts, the instance is always different

How do I specify the uri to get the same (and correct) instance of my 

This method of information sharing was introduced for this purpose, 
wasn't it??


View raw message