• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Mock question  RSS feed

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the following servlet code:
//...
public void service (HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
//1
}
Which of the following can be used at //1 to retrieve a JavaBean named
address present in the application scope? (Select one)
a getServletContext().getAttribute("address");
b application.getAttribute("address");
c request.getAttribute("address",APPLICATION_SCOPE);
d pageContext.getAttribute("address",APPLICATION_SCOPE);
 
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The correct answer is a.

Best regards ...
 
Tiffiny Yang
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply.

What's wrong with choice d?
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Choice d is using of of the implicit objects of the _jspService method in the Servlet generated by a JSP.

Regards ...
 
Tiffiny Yang
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

Another question:
in the _jspService() method, the only visible objects are : request/response/out, correct?
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

They are :

JspWriter out
HttpServletRequest request
HttpServletResponse response
HttpSession session
ServletContext application
ServletConfig config
JspException exception
PageContext pageContext
Object page

Best of luck ...
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!