• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Using default ServletContext?

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A quick question for all you Servlet API gurus :-)
I have some information that I need to store past the end of an HttpSession lifecyle.
This information needs to be available to all servlets in the web application.
Regarding the ServletContext, the Servlet Specification states:


SRV.3.2 Scope of a ServletContext Interface
There is one instance object of the ServletContext interface associated with each
web application deployed into a container. In cases where the container is
distributed over many virtual machines, a web application will have an instance of
the ServletContext for each VM.
Servlets in a container that were not deployed as part of a web application are
implicitly part of a �default� web application and have a default ServletContext.
In a distributed container, the default ServletContext is non-distributable and
must only exist in one VM.


Therefore, this information cannot be stored in the web application's ServletContext. However, we are using tomcat, which can be configured to allow access to the default context with the following entry in the server.xml configuration file:

This default context is guaranteed to be in a single JVM only, so perhaps we can store stuff in there. Glorious hack, or dangerous approach?
For example, the following JSPs can share information between web applications, so I am guessing this approach should work for distributed web applications also:
File 1:

File 2:

Comments please :-)
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Therefore, this information cannot be stored in the web application's ServletContext.


Why do you think this? You haven't described anything about your setup that precludes using the web app's servlet context.
 
I'm doing laundry! Look how clean this tiny ad is:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic