Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question Bank ID : 6

 
mocca az
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings Carl,
I have question regarding the Question Bank ID 6. It marks these two options as correct answers. I understand the doGet part
doGet(HttpServletRequest request, HttpServletResponse response)
{
String name = request.getParameter("name");
...
but i am confused on this part. API says following for service method
public void service(ServletRequest req,
ServletResponse res)
throws ServletException,
java.io.IOException
So it is (ServletRequest, ServletResponse) not HttpServletRequest, HttpServletResponse). Can you elaborate on this a little bit?
service(HttpServletRequest request, HttpServletResponse response)
{
String name = request.getParameter("name");
...
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 service methods in HttpServlet
public void service(ServletRequest req, ServletResponse res)
throws ServletException, java.io.IOException
and
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, java.io.IOException
You could over ride either in your servlet though in the JavaDoc's it specifically states for the first (public method):
"Dispatches client requests to the protected service method. There's no need to override this method."

------------------
I Hope This Helps
Carl Trusiak, SCJP2
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic