This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JavaRanch MockExamQuestion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JavaRanch MockExamQuestion" Watch "JavaRanch MockExamQuestion" New topic
Author

JavaRanch MockExamQuestion

Divya Guttikonda
Ranch Hand

Joined: Mar 09, 2005
Posts: 47
Here is a Mock Exam Question from JavaRanch:

A client types the URI :
http://www.someserver.com/servlet/SomeServlet?name=fred
The value of name can be obtained by:

a)doGet(HttpServletRequest request, HttpServletResponse response)
{
String name = response.getParameter("name");
...


b) service(HttpServletRequest request, HttpServletResponse response)
{
String name = request.getParameter("name");
...


c)doGet(HttpServletRequest request, HttpServletResponse response)
{
String name = request.getInitParameter("name");
...


d)doGet(HttpServletRequest request, HttpServletResponse response)
{
String name = request.getParameter("name");
...

The answer given is b, but i think the correct answer is d.Can anybody help me with this?

Thanks
Divya.
Sirisha Reddy
Ranch Hand

Joined: Jun 09, 2003
Posts: 75
i dont see why d is not correct answer ?!


SCJP 1.4
shiva viswanathan
Ranch Hand

Joined: Aug 12, 2004
Posts: 152
Hey I think both b and d are correct answers since ultimately the service method calls the doGet method passing the same HttpServletRequest
method
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JavaRanch MockExamQuestion
 
Similar Threads
HTTP method GET is not supported error when the JSP is making POST request to the servlet
Running a servlet on Tomcat using Eclipse
how to call JSP from Servlet
Database Access Repeated Each Time
Error 400: