• Post Reply Bookmark Topic Watch Topic
  • New Topic

quiz question from jdiscuss

 
Swati Udas
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 correct option.

1>pageContext and config
2>application and config
3>config and pageContext
4>application for both
5>config for both.

Answer is 4.
I havent understood the question. Could someone explain please !
 
Swati Udas
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The application implicit variable is of type javax.servlet.ServletContext, which has the methods- getResource() and getResourceAsStream() to get a resource and getRequestDispatcher() to forward a request.
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.

Found this explaination there itself
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The application implicit object represents a handle to the ServletContext. Look up ServletContext and you will see that is has methods for obtaining a Resource (getResource) and a RequestDispather (getRequestDispatcher).
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!