• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doPost and service

 
krishna
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anybody tell me the difference between service method and doPost in a HttpServlet.
thanx
Kris
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The service() method receives standard HTTP requests and dispatches them to the doXXX methods defined in the servlet class.
Suppose u specify method="post" in your HTML from then the service method of your servlet will be called and from that method doPost method gets called.
 
Doug Wang
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So dont override the default service() method. Just leave it alone. Thus you gain flexibility.
[ April 23, 2002: Message edited by: Doug Wang ]
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah , Servlet API framework is general in nature : init() service() destroy().
HttpServlet gets specific to HTTP protocol so doGet() , doPost() etc r there
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"krishna"
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at JavaRanch's naming policy. . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic