title: Requestdispatcher Nullpointer Exception
body: <p>i have following Servlet Code:</p>
  
  <pre><code>@WebServlet("/Login")
  public class Login extends HttpServlet {
  private static final long serialVersionUID = 1L;
  public String lang = "";   
  /**
   * @see HttpServlet#HttpServlet()
   */
  public Login() {
      super();
      // TODO Auto-generated constructor stub
  }
  
  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
  }
  
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
      String lcLog = request.getParameter("LogType").toUpperCase();
      switch(lcLog)
      {
          case "LOGIN":
              try {
                  boolean llErfolg = doLogin(request.getParameter("user").toUpperCase(),request.getParameter("pw"));
                  if(llErfolg==true)
                  {
                      System.out.println("Login");
                      HttpSession session = request.getSession();
                      session.setAttribute("username", request.getParameter("user").toUpperCase());
                      session.setAttribute("Language", lang);
                      request.getRequestDispatcher("/WEB-INF/jsp/view/Kacheln_Test.jsp").forward(request, response);
                  }
                  else
                  {
                      System.out.println("Login Failed");
                      request.setAttribute("LogInFailed", true);
                      request.getRequestDispatcher("/WEB-INF/jsp/view/Startseite.jsp").forward(request, response);
                  }
              } catch (SQLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              break;
          case "LOGOUT":
              System.out.println("Logout");
              HttpSession session = request.getSession();
              session.invalidate();
              request.getRequestDispatcher("/WEB-INF/jsp/view/Startseite.jsp").forward(request, response);
              break;
          default:
              System.out.println("Warum?");
              break;
      }
  }
  </code></pre>
  
  <p>Everything worked fine until now, but recently whenever i get so the case "LogOut", i get a Nullpointer Exception at the Dispatcher and i have absolutely no idea why, because it worked a few days before.</p>
  
  <p>I have following Kacheln_Test.jsp file, maybe there is the root of the problem, because when i click on "Kunden" the same error happens</p>
  
  <pre><code>&lt;c:url var="post_url2" value="/Login" /&gt;
  &lt;form id="LogOut" method="POST" action="${post_url2}" name="LogOut"&gt;
      &lt;input type="hidden" id="LogType" name="LogType" value = "" /&gt;
      &lt;fmt:message key="Kacheln.Label.Angemeldetals"/&gt;&amp;emsp; &lt;%=session.getAttribute("username") %&gt;,
      &lt;a href="javascript:{}" onclick="ausloggen_setzen('LogOut');"&gt;&lt;fmt:message key="Kacheln.Label.LogOut"/&gt; &lt;/a&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>same error here</p>
  
  <pre><code>&lt;div class="image-container"&gt;
      &lt;div class="frame"&gt;
         &lt;input class="live-slide"  type ="image" src="Images/Kunden.png" onClick="return setValue('Mail')" /&gt;
      &lt;/div&gt;
      &lt;div class="image-overlay" onclick="return setValue('Kunden')"&gt;
          &lt;fmt:message key="Kacheln.Button.Kunden"/&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>that are the functions called</p>
  
  <pre><code>&lt;script&gt;
      function ausloggen_setzen(lcTest)
      {
          document.getElementById('LogType').value = lcTest;
          document.getElementById('LogOut').submit();
          return true;
      }
      function setValue(lcArt)
      {
          document.getElementById("OF").value = lcArt;
          document.getElementById("OFform").submit();
          return true;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>hope somebody can help, i think it's just a small thing but i don't know the reason</p>
  
  <p>Error Stacktrace:</p>
  
  <pre><code>Jul 12, 2017 8:46:22 AM org.apache.catalina.core.StandardWrapperValve    
  invoke
  SCHWERWIEGEND: Servlet.service() for servlet [Login] in context with path
   [/Tuev_Test] threw exception [org.apache.jasper.JasperException:   
  java.lang.NullPointerException] with root cause
  java.lang.NullPointerException
  at     org.apache.jsp.WEB_002dINF.jsp.view.Menu_jsp._jspService(Menu_jsp.java:251)
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:716)
  at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:584)
  at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:523)
  at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:885)
  at org.apache.jsp.WEB_002dINF.jsp.view.Startseite_jsp._jspService(Startseite_jsp.java:136)
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:716)
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)
  at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
  at Login.doPost(Login.java:73)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:616)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
  at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1533)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1489)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Greetings,</p>
  
  <p>Kevin</p>