title: override doGet in servlet
body: <p>I am trying to make a servlet, and trying to override my <code>doGet</code> method. There is an error in the <code>@Override doGet</code></p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          processRequest(request, response);
      }
  </code></pre>
  
  <p>It is under processRequest the error comes. The concrete error message is: </p>
  
  <pre><code>The method processRequest(HttpServletRequest, HttpServletResponse) is undefined for the type 
  CookieUsageServlet
  </code></pre>
  
  <p>Does anybody know why I get this error?</p>
  
  <pre><code>   package ExamplePackage;
  
  import java.io.IOException;
  import java.util.Date;
  import java.io.PrintWriter;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.Cookie;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  @WebServlet("/CookieUsageServlet")
  public class CookieUsageServlet extends HttpServlet {
      private static final long serialVersionUID = 1L;
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          doPost(request, response);
      }
  
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          Cookie cookie = getCookie(request, response);
          printResponse(response, cookie);
      }
  
  
      private Cookie getCookie(HttpServletRequest request, HttpServletResponse response) {
          Cookie cookie = null;
          Cookie[] cookiesArray = request.getCookies();
          if(cookiesArray != null) {
              for(int x = 0; x &lt; cookiesArray.length; x++) {
                  if(cookiesArray[x].getName().equals("test_cookie")) cookie = cookiesArray[x];
              }
          }
          if(cookie != null) {
              System.out.println("cookie retrieved");
          } else {
              int timeToExpireCookie = new Integer(getServletContext().getInitParameter("time-to-expire-cookie")).intValue();
              cookie = new Cookie("test_cookie", Long.toString(new Date().getTime()));
              cookie.setMaxAge(timeToExpireCookie);
              cookie.setPath(request.getContextPath()); // Sti til login
              System.out.println("Cookie created...");
              response.addCookie(cookie);
          }
          return cookie;
      }
      private void printResponse(HttpServletResponse response, Cookie cookie) throws IOException {
          PrintWriter printWriter = response.getWriter();
          response.setContentType("text/html");
          printWriter.println("&lt;html&gt;");
          printWriter.println("&lt;head&gt;&lt;title&gt;Cookie In JAVA servlet&lt;/title&gt;&lt;/head&gt;");
          printWriter.println("&lt;body&gt;");
          printWriter.println("&lt;cookie name: " + cookie.getName() + "&lt;br&gt;");
          printWriter.println("&lt;cookie value: " + cookie.getValue() + "&lt;br&gt;");
          printWriter.println("&lt;time to expire cookie in seconds: " + cookie.getMaxAge() + "&lt;br&gt;");
          printWriter.println("&lt;/body&gt;");
          printWriter.println("&lt;/html&gt;");
  
  
      }
  }
  </code></pre>