title: java.lang.NullPointerException occurs when i update?
body: <p>I got Null pointer exception
  <code>"java.lang.NullPointerException"</code>
  refer below code for reference
  Everything should be fine but not able to update data to the database(mySql)</p>
  
  <pre><code>&lt;% try{
          //reading request parameters
  
            String projectName=request.getParameter("projectName").trim();
            String status=request.getParameter("status").trim();
  
            //String user = session.getAttribute("user").toString();
            Connection connection = DAO.getConnection();
            PreparedStatement pstmt = connection.prepareStatement("update project set status=? where projectName=?");
  
            pstmt.setString(1,status);
            pstmt.executeUpdate();                    
            out.println("&lt;h2 style='color:green'&gt;Project Status has been updated&lt;/h2&gt;");
      }
      catch(Exception ex)
      {
            ex.printStackTrace();
            out.println("&lt;h2 style='color:red'&gt;Please login to update your Status&lt;/h2&gt;");
      }
  %&gt;
  </code></pre>
  
  <p>Not able to update because of exception
  refer below
  Please anyone suggest me how to solve this exception...</p>
  
  <blockquote>
    <p>java.lang.NullPointerException    at org.apache.jsp.MyWorkPanelAction_jsp._jspService(MyWorkPanelAction_jsp.java:93)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)     at
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
      at
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)     at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      at
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
      at
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      at
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)</p>
  </blockquote>