title: Cannot get a RequestDispatcher
body: <p>I've read lots of similar questions and tryed all suggested methods for fixing the problem, however it's unsuccessfully. Now I really don't have any ideas what to do with this (localhost:8080/testWebApp/home):</p>
  
  <pre><code>HTTP Status 500 -
  ...    
  exception
  
  java.lang.NullPointerException
      test.web.servlet.TestServlet.doGet(TestServlet.java:37)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>I use maven 3.3.9 and tomcat7 7.0.70-1. My project directory has the following hierarchy:</p>
  
  <pre><code>webApp/
     pom.xml
        src/
           main/
              java/
                 test/web/servlet/
                          TestServlet.java
           webapp/
              index.html
              WEB-INF/
                 views/
                    home.jsp
                 web.xml
  </code></pre>
  
  <p>Here is the TestServlet code:</p>
  
  <pre><code>package test.web.servlet;
  
  
  import java.io.IOException;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.ServletConfig;
  import javax.servlet.ServletContext;
  import javax.servlet.ServletOutputStream;
  
  
  @WebServlet(urlPatterns = { "/home"})
  
  public class TestServlet extends HttpServlet {
  
      @Override    
      public void init(ServletConfig config) throws ServletException {
          super.init(config);
      }
  
      public TestServlet() {
          super();
      }
  
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
          RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/views/home.jsp");
          //The following attempts are unsuccessful too:
          //RequestDispatcher dispatcher = request.getRequestDispatcher("/home.jsp");
          //RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/views/home.jsp");
          dispatcher.forward(request, response); // error (37 line)
      }
  
      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          doGet(request, response);
      }
  }
  </code></pre>
  
  <p>Here is web.xml code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  
  &lt;!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_4.dtd"&gt;
  
  &lt;web-app&gt;
  
      &lt;welcome-file-list&gt;  
          &lt;welcome-file&gt;home&lt;/welcome-file&gt;
          &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;  
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>home.jsp code:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;    
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;title&gt;Home Page&lt;/title&gt;
      &lt;/head&gt;
  
      &lt;body&gt;    
  &lt;%--         &lt;jsp:include page="main.jsp"&gt;&lt;/jsp:include&gt; --%&gt;
  
          &lt;h3&gt;Home&lt;/h3&gt;
          &lt;br&gt;&lt;br&gt;
          &lt;b&gt;You have the following options:&lt;/b&gt;
          &lt;ul&gt;
              &lt;li&gt;Login&lt;/li&gt;
          &lt;/ul&gt;    
      &lt;/body&gt;    
  &lt;/html&gt;
  </code></pre>
  
  <p>Some useful lines from pom.xml:</p>
  
  <pre><code>    &lt;plugin&gt;
          &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt; 
          &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.2&lt;/version&gt;
          &lt;configuration&gt;
              &lt;server&gt;tomcat-7.0.70-1&lt;/server&gt;
              &lt;url&gt;http://localhost:8080/manager/text&lt;/url&gt;
              &lt;path&gt;/testWebApp&lt;/path&gt;
          &lt;/configuration&gt;
      &lt;/plugin&gt; 
  </code></pre>
  
  <p>Thank you for help!</p>