• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question Bank ID : 6

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
...
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic