• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServletContext

 
Tejas Tambe
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With reference to Hanumant Deshmukh's book,
Chapter 6, Section 6.1
IT's said that
every web application has exactly one instance of ServeltContext (assuming that the servlet container is not distributed across multiple JVMs).

Does it mean that if servlet container is distributed across multiple JVMs, then there will be more that 1 instance of ServletContext ??
If yes, is it mandatory ??
Can any 1 please explain me this ??
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure its Chapter 10 "Developing thread-safe servlets" that will explain things pretty well.
Basically if you have a distributed web application (using more than one JVM) -- you'll get one ServletContext per JVM. And yes, that's mandatory.
From the Servlet 2.3 spec:
SRV.10.6 "Distributed Containers"
In distributed web containers, HttpSession instances are scoped to the particular VM servicing session requests, and the ServletContext object is scoped to the web container's VM....
 
S. Ganapathy
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do agree with Jessica. There is one instance of ServletContext per JVM in a distributed web application, but default web application (ROOT in case of Tomcat) has only one instance among multiple JVMs in a distributed environment.
At this stage, Tejas Tambe, you will get confused. Give a through read of the entire book, surely you will understand in later chapters. Don't worry about this at this stage. Your question is answered in the book.
 
Tejas Tambe
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
Jesica n Venkat
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic