File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sharing variable across applications?

 
Ivan Jouikov
Ranch Hand
Posts: 269
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any direct way to do that, other than some DB-workaround?

I noticed in Tomcat administration there's an "Environment Entries" section, which has some values. Could that be it?
 
Anthony Watson
Ranch Hand
Posts: 327
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get a reference to another application's ServletContext like this:

this.getServletContext().getContext(uriPath);

Then, you can save an attribute into that context. Just remember, servlet context attributes are not inherently thread safe!
 
Anthony Watson
Ranch Hand
Posts: 327
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also use the above described method but instead of putting a variable into the servlet context, you put the variable into request context, get a RequestDispatcher, and forward the request to another application.
 
Ivan Jouikov
Ranch Hand
Posts: 269
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank thee!
 
steve souza
Ranch Hand
Posts: 862
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what the j2ee spec says, but my experience is that static variables in server scope are shared by all applications. For example a static variable in the a jar in the servers class path.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic