Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Question Bank ID : 6

 
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");
...
 
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
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic