• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mock question , wrong answer

 
ani jadhao
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In one of mock of javabeat , I came across of below question.

Which of the following interfaces can be used to acquire a reference to
ServletContext object?
a. HttpServletRequest
b. HttpServletResponse
c. HttpSession
d. HttpServletConfig
e. ServletConfig

Answrs given are : A and E .
But shouldn't the answer include option C also as interface HttpSession also has a method called getServletContext?
Please help me clearing this doubt.
thanks
Ani

 
Rob Spoor
Sheriff
Pie
Posts: 20753
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And A should be wrong - neither HttpServletRequest nor ServletRequest has any methods that return a ServletContext object.
 
Milton Ochoa
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both of you all right.!!!

the answer will be:

C: HttpSession
E: ServletConfig

I think so!
 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes c correct option ....
 
santosh joshi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes both C and E are correct
getSession().getServletContext()
and
servletConfig.getServletContext()
 
raj niru
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javabeat questions are copied from Hanumant Deshmukh's ebook
 
Santhi Bharath
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Hi Stefan,
You are referring to SRV 2.2 specs. From SRV 2.3 they have added a method getServletContext() in javax.servlet.http.HttpSession class

So, both C and E should be right answers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic