title: What is 'service' method in HttpServlet class?
body: <p>Below is a simple servlet written for learning.</p>
  
  <pre><code>package com.example.tutorial;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  
  public class ServletExample extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          PrintWriter out = response.getWriter();
          out.println("Hello Java!");
      }
  
  }
  </code></pre>
  
  <p>When a browser hits this URI: <code>http://localhost:8081/ServletsJSPExample/servletexample</code>,</p>
  
  <p>By analyzing the request header of http packet, it shows <code>GET</code> request sent from the browser. But, In my servlet, I do not have <code>GET</code> request to process.</p>
  
  <p>So,</p>
  
  <p>When does <code>service</code> method gets invoked?</p>
  
  <p>Why does <code>service</code> method receives this <code>GET</code> request?</p>