Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6177557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:17:48+00:00 2026-05-24T00:17:48+00:00

I was reading a book on servlets, in that book a brief explanation is

  • 0

I was reading a book on servlets, in that book a brief explanation is given about the servlet class, as well as the HttpServlet class.

There is one example for filling in a form- for that form, the servlet’s doPost() method is overridden by the class. But for another example of a login form, the service() method is overridden instead.

I want to know why the 2 different approaches- I thought that usually we put our custom code into doPost() (or doGet()) and let service() remain as it is. Is there any reason behind using either one of the 2 approaches, or can I use both approaches in any situation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:17:49+00:00Added an answer on May 24, 2026 at 12:17 am

    Do not override service() method. The preferred approach is using doPost() for post and doGet() for get. Here is an excellent post on what each does. http://www.jguru.com/faq/view.jsp?EID=47730

    If you must respond to requests made by a client that is not using the
    HTTP protocol, you must use service().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading a book on LINQ I'm thinking about re-writing a mapper class that
While reading a book about JavaScript I stumbled across an example: var names =
I mentioned in one of my earlier questions that I'm reading book C++ Coding
While I was reading the book - O'Reilly Java Servlet Programming. There was a
I am reading a book about Java and it says that you can declare
I'm reading the book LINQ Pocket Reference and there is a particular example (slightly
While reading the book Programming Ruby , one example shows how blocks can be
I was reading a book on Java Servlets where I came across HTTPSessionActivationListener .
Recently, I was reading book about Erlang which has hot deployment feature. The deployment
I am reading the book Think Python by Allen Downey. For chapter 4, one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.