• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Defaul ServletContext ...??? Question

 
Leandro Melo
Ranch Hand
Posts: 401
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
What's exactly a default servlet context? How do I configure it?
This is a question from jdiscuss about this.

-----------
Assuming that the servlet container is distributed across multiple JVMs, which of the following statements are correct? (Select 2 correct options.)

1 - A separate instance of a non-default servlet context will be available on each of the JVMs.

2 - A separate instance of all servlet context will be avaible on each of the JVMs

3 - The default servlet context will be present only on one of the JVMs.

4 - There is only one instance of servlet contexts across all the JVMs.

5 - None of the above.

Option 1 and 3 are actually the specification of the behaviour of ServletContexts.
Default servlet context is provided to servlets that are not deployed as a part of some webapplication. They are considered to be a part of "default" webapplication.
 
Osama Hasan
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
There is one default web application in the servlet container. In Tomcat, the directory named ROOT refers to the default web application. The servlet context of this web application is called the default servlet context.
 
amit taneja
Ranch Hand
Posts: 813
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Osama Hasan:
Hi!
There is one default web application in the servlet container. In Tomcat, the directory named ROOT refers to the default web application. The servlet context of this web application is called the default servlet context.


so what is the final answer from list of choices and why ?
 
Osama Hasan
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The correct answers as mentioned in the first post are 1 and 3. The Java Servlet specification guarantees that in a distributed environment each web application has one Servlet Context on each JVM except the default web-application whose Servlet Context exists on only one JVM.
Hope it helps.
 
Sumeet Raheja
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet Context is one per application with in one JVM , but in distributed application Servlet Context is per JVM. That means if one Application is distributed among two JVM then there will be 2 Servlet Context in total, one per JVM
 
Leandro Melo
Ranch Hand
Posts: 401
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sumeet, we're talking here not about "the" servlet context, but specifically about the "default" servlet context.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic