Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJWCD
Search Coderanch
Advance search
Google search
Register / Login
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Devaka Cooray
Liutauras Vilda
Sheriffs:
Jeanne Boyarsky
paul wheaton
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Lou Hamers
Piet Souris
Frits Walraven
Forum:
Web Component Certification (OCEJWCD)
j2eecertificate mock exam question
vijaya bacina
Ranch Hand
Posts: 155
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Consider the following code fragment, how can you obtain the ServletContext at line 5? [Check all correct answers] 1.public class Boarder extends HttpServlet { 2.protected void doGet(HttpServletRequest req,HttpServletResponse resp) 3.throws ServletException, IOException { 4. ServletContext context = null; 5.// insert code here 6. } 7.} Choices 1 context = getServletContext(); 2 context = getServletConfig().getServletContext(); 3 context = req.getServletConfig().getServletContext(); 4 context = req.getSession().getServletContext(); 5 context = resp.getServletContext();
Answers given r 1,2,4
my doubt is Does HttpSession class has the method getServletContext??
Thx
Srinivasan Rengan
Ranch Hand
Posts: 122
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Yes offcourse.
HttpSession class has a getServletContext() through which we acquire the reference to ServletContext object.
Srini
SCJP, SCWCD, SCBCD (EJB 2.x and EJB 3), OCA, SCDJWS
Will Lee
Ranch Hand
Posts: 58
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
take a look at session API, you will see this method.
What's more, I believe if session obj. can't get servletContext, there's no way for Http***Listener to know anything about the context.
SCJP 1.4, SCWCD, SCDJWS
vijaya bacina
Ranch Hand
Posts: 155
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanx for ur replies..
I'm full of tinier men! And a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
j2eeCertificate Ques.
Why getting Exception...
Servlet concepts doubts
Order of Loading Servlets, Context Listeners, Tag classes and Filters
which is thread safe ?
More...