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

Protected doGet/doPost service methods

 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Service( doGet/doPut) methods in HttpServlets are declared protected ( though these can be overridden to be public )
So we should quote them as such , i guess.
But i found Miftah khan's Notes ( also Velmurugan's notes ) say :
1.1.1. GET: public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
1.1.2. POST:public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
1.1.3. PUT: public void doPut(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
Any specific reason for that ? Am i missing something ?

------------------
Gagan (/^_^\) SCJP2
Die-hard JavaMonk -- little Java a day , keeps u going .
 
Win Yu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got same question. Can anyone answer this.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bad idea. The doGet(), doPost() and doPut() methods are not part of the public interface of a servlet. The public interface for incoming requests is the service(ServletRequest,ServletResponse) method; only this, together with the other methods from the Servlet interface, should be public. HttpServlet implements the service method by dispatching the request to doGet() and friends.
- Peter
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But i found Miftah khan's Notes ( also Velmurugan's notes ) say :
1.1.1. GET: public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
1.1.2. POST:public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
1.1.3. PUT: public void doPut(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
Sorry guys, this was definitely a typo. I will correct it in the next update of my notes, which should be within a week.
Thanks,
-Miftah

[This message has been edited by Miftah Khan (edited November 03, 2001).]
 
Win Yu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic