• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock Exam - JSP Implicit variables

 
Roopa Maheshkumar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source: Enthuware mock exam

Which of the following implicit variables should be used by a jsp page to access a resource and to forward a request to another jsp page?

Select 1 option
options :-

1.config for both.

2.application and config

3. application for both

4.config and pageContext

5.pageContext and config

Given answer is 3. But my guess is that option 4 is also correct.

From config implicit variable, servlet context can be obtained to get access to resources and pageContext.forward() methods can be used to forward a request.

Please help me in understanding. Planning to give the exam in a couple of days.

Thanks!!
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3817
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Roopa,
Your reasoning is correct and it is also mentioned in the explanation provided with the question, which says, "Although, you can also use 'config' to get ServletContext (and then call the above methods) but it is better to select 'application' because can be used directly."

In the actual exam, if you encounter any such ambiguity, our suggestion is to select the most obvious answer instead trying to out think the examiner because even if your reasoning is correct, you will be losing marks.

HTH,
Paul.
 
Roopa Maheshkumar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks paul for your quick response!!

It seems to me that 'application' may be more revelant in getting resources but not in forwarding to a jsp..

pageContext.forward(path) seems more revelant than

application.getResourceDispatcher("path").forward(req,res)

Thanks!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic