• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mock Question Doubt

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic