• Post Reply Bookmark Topic Watch Topic
  • New Topic

Mock Question Doubt  RSS feed

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements are true?
Choose at least one answer.
A. Every (non distributed) web application has only one instance of ServletContext Correct
B. Every instance of HttpServlet has only one instance of ServletContext Incorrect
C. The ServletContext object is retrieved via the getServletContext method of ServletConfig Correct
D. The ServletConfig object is retrieved via the getServletConfig method of ServletContext Incorrect

my question is why is option 2 is wrong.(It is from examulator.com)
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Looks like a mistake to me.

Could it be the question is badly worded?
"Every instance of HttpServlet has only one instance of ServletContext" could be read as
a) Every single instance points to one and only one instance of a ServletContext object (i.e. they don't contain a map of them, just a reference to one, which would be true)
b) Every single instance points to the exact same ServletContext (which would be false for distributed applications).

Make sense?

MG
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its because if the web application is in a distributed environment then each servlet will have one ServletContext per JVM
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!