Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

ServletContext

 
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 ??
 
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....
 
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
 
Cob is sand, clay and sometimes straw. This tiny ad is made of cob:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic