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 8815523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:24:04+00:00 2026-06-14T04:24:04+00:00

After I make a GET request to the following servlet, the text ‘In service

  • 0

After I make a GET request to the following servlet, the text ‘In service method’ is written and can not explain it. why is that?

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class MyServlet extends HttpServlet {
   public void service(HttpServletRequest req,
                       HttpServletResponse resp) throws IOException {
      Writer out = resp.getWriter();
      out.write("In Service method");
   }

   public void doGet(HttpServletRequest req, HttpServletResponse resp) 
                                                        throws IOException {
      Writer out = resp.getWriter();
      out.write("In get method");
   }
}
  • 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-06-14T04:24:06+00:00Added an answer on June 14, 2026 at 4:24 am

    The default implementation of HttpServlet#service() does exactly that job. Here’s an extract of its javadoc:

    Receives standard HTTP requests from the public service method and dispatches them to the doXXX methods defined in this class. This method is an HTTP-specific version of the Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) method. There’s no need to override this method.

    It delegates to the appropriate servlet method depending on the HTTP method. E.g. when request.getMethod() equals to "GET", then it delegates to doGet(). By the way, have you read the last sentence as well?

    In any way, you should basically be performing the very same job yourself.

    @Override
    public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        Writer out = resp.getWriter();
        out.write("In Service method");
    
        if ("GET".equalsIgnoreCase(req.getMethod())) {
            doGet(req, resp);
        }
        // Check other methods as well!
    }
    

    Or just call the super method so that it can do its job.

    @Override
    public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        Writer out = resp.getWriter();
        out.write("In Service method");
        super.service(req, resp);
    }
    

    Or just don’t override it at all.

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

Sidebar

Related Questions

When I run make (after running qmake) I get the following error: /usr/bin/ld: cannot
We get the following error; The request was aborted: Could not create SSL/TLS secure
I am following along with this Django blog tutorial and can not get the
I'm trying to install memcached-1.2.8-repcached-2.2.1 I have the following error after running make :
I'm designing a Web service. The request is idempotent, so I chose the GET
I've created a graphing application that calls a web service. The user can zoom
I am working on a method to activate new members. I get the following
With the following form <form target="dialogiframe" action="ConfigUpdate.cvx" id="TestForm" name="TestForm" method="get"> <input name="test" type="text" size="40"
I got the following basic script who make a basic POST request (I just
I have a .NET 2.0 application that uses WSE 3.0 to make web service

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.