aspose file tools*
The moose likes Servlets and the fly likes ServletContexts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletContexts" Watch "ServletContexts" New topic
Author

ServletContexts

eswar kumar
Ranch Hand

Joined: Oct 20, 2002
Posts: 98
How many ServletContexts are available in a servlet container/JVM?
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Usually one for each distinct loaded application.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
eswar kumar
Ranch Hand

Joined: Oct 20, 2002
Posts: 98
ThanQ Frank but im asking. can we keep more than one ServletContext in a servlet container
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
yes. That's what I wass trying to explain. A servlet container holds separate "applications", and each such application has its own servlet context.
If you want more than one "context" in a single application, one way is to put a Map in the application context for each "sub context", and store your different objects in there.
Or have I misunderstood what you are asking?
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
Basically, for each .WAR file deployed, the server creates/manages one ServletContext.
ServletContext is an interface with the implementing class provided by the container. You should not try to create one yourself. If you need a place to store other information within a web application, utilize something like Frank has outlined and store it in the one and only ServletContext your app should reference.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletContexts
 
Similar Threads
servlet config and servlet context
setSessionContext
What is the diff between a RequestDispatcher object obtained from Request & Context
how to change values in servlet context
Passing variables from class to class (SOLVED)