*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes object can access the ServletContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "object can access the ServletContext" Watch "object can access the ServletContext" New topic
Author

object can access the ServletContext

Parth Twari
Ranch Hand

Joined: Jan 20, 2010
Posts: 163
Which implicit object can access the ServletContext?

a. server

b. request

c. session

d. response

e. application

Source: SAI

What is your final answer?


Parth Tiwari
| Pursuing Bachelor of Engineering | OSUM Club Leader | SCJP 6 | SCWCD 5 |...
k space
Ranch Hand

Joined: Jun 25, 2002
Posts: 104
I believe the answer is C, as HttpSession provides the getServletContext method.


SCEA | SCBCD | SCWCD | SCJP - The kSpace
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Parth, look at a source like this one to find out which implicit JSP object is of what type and then try to see which object will have access to the ServletContext object...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1665
    
  25

What is your final answer?


I would say: b,c and e

If the Session has a method getServletContext() then you can also access it via the request object (request.getSession().getServletContext().
The implicit object application has a getContext() method as well.

Regards,
Frits
Parth Twari
Ranch Hand

Joined: Jan 20, 2010
Posts: 163
My answer was same as
k space's
specially because it was asked to select only 1 option.

I might have thought on Frits lines if more than one option was asked to be selected.

But

see their take

JSP Specification, Version 2.0 (section 1.8.3)

Option E is correct. The application implicit object is equivalent to the ServletContext.

Options B, C, and D are incorrect because these implicit objects are used to access other scopes.

Option A is incorrect because that implicit object does not exist.


So what shall we decide?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1665
    
  25

Options B, C, and D are incorrect because these implicit objects are used to access other scopes.

This sounds rather vague to me... they (without the response-object) can still get to the context..

Regards,
Frits
Parth Twari
Ranch Hand

Joined: Jan 20, 2010
Posts: 163
the questions language is not right I feel, they did not write correctly what they wanted to ask.

it should have been
Which implicit object refers the ServletContext?


anyways I feel the doubt is in everyone's mind, so its resloved for me.

Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Parth Twari wrote:the questions language is not right I feel, they did not write correctly what they wanted to ask.


me too, thanks for sharing!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: object can access the ServletContext