*
The moose likes Servlets and the fly likes Inter servlet access in single web server. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Inter servlet access in single web server." Watch "Inter servlet access in single web server." New topic
Author

Inter servlet access in single web server.

Tejas Aryan
Greenhorn

Joined: Apr 12, 2009
Posts: 22
The tomcat runs on one JVM. Suppose the tomcat has 2-3 web applications, say A, B and C. A class in web app A declares a static variable int xA = 5; Since there is only one JVM this variable is created there. My question is can class in other web application,B, access this variable through some means if not directly ?. I don't want to use any web services/ rmi etc.
Tejas Aryan
Greenhorn

Joined: Apr 12, 2009
Posts: 22
Read in one of the forum that tomcat's inbuilt jndi can be used to attach the object and then this object can be referenced from other servlet context. I have not tried this, though. However, even if this works this will tie my application to tomcat. Any other options ?
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

Using JNDI to access/use resources is a standard JEE practice and does not tie your application with any Application Server.

I a new Application Server, you have to create JNDI resources again and use them, that' all.


S.D. MADHAN
Not many get the right opportunity !
 
wood burning stoves
 
subject: Inter servlet access in single web server.
 
Similar Threads
Single JDBC class for multiple Java Applications
A doubt with Singleton pattern
Using static varaibles in Threads
EJB based Architectural problem ! pls help with suggestions
Does static has only one instance?