File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes ServletContext Confusion... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletContext Confusion..." Watch "ServletContext Confusion..." New topic
Author

ServletContext Confusion...

Navin Pillu
Ranch Hand

Joined: Apr 19, 2005
Posts: 103
Hi All

I have very basic question about ServletContext. Somewhere i read There is only one ServletContext per JVM & somewhere i read for Each web application has one & only one ServletContext. Does it mean if i have 10 web application their will be 10 ServletContext.

Which one is correct .Really confused.

Thanks in advance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61209
    
  66

There is one Servlet Context per web application.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Navin Pillu
Ranch Hand

Joined: Apr 19, 2005
Posts: 103
HI
You mean There is a single ServletContext for each Web application, for each Java virtual machine. Am i right?

Thanks for respond
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61209
    
  66

The number of JVMs is moot. Each web app has its own ServletContext.
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi Bear,

There is something different in Servlet Spes. on page 31.

Threre is one instance object of 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 JVM

Servlets in a container that were not deployed as part of Web application are implicilty part of "default" web application and have a default ServletContext. In a distributed container, the default ServletContext is non-distributable and must only exists in one JVM


Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Navin Pillu
Ranch Hand

Joined: Apr 19, 2005
Posts: 103
Thanks a lot Bear & Naredra


[ July 02, 2005: Message edited by: Navin Pillu ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61209
    
  66

There is something different in Servlet Spes.


That simply confirms that eash web app has its own context. Multiple JVM's complicate that (in that web apps in separate JVMs will each have their own context), but does not change the fact that web apps each have a unique context (which was my point if I did not make it clear).
[ July 02, 2005: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletContext Confusion...