title: why i'm getting this error of HTTP Status 500?
body: <p>I've created a simple JSP page and made a Servlet called <code>UserController.java</code> which is inside the package <code>com.pro3.controller</code>. In jsp page I have a form with get method. When I submit the form it fails with following exception:</p>
  <p>HTTP Status 500 - javax.servlet.ServletException: Error instantiating servlet class com.pro3.controller.UserController</p>
  <pre><code>--------------------------------------------------------------------------------
  
  type Exception report
  
  message javax.servlet.ServletException: Error instantiating servlet class com.pro3.controller.UserController
  
  description The server encountered an internal error that prevented it from fulfilling this request.
  
  exception 
  
  org.apache.jasper.JasperException: javax.servlet.ServletException: Error instantiating servlet class com.pro3.controller.UserController
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:502)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:412)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
  
  
  root cause 
  
  javax.servlet.ServletException: Error instantiating servlet class com.pro3.controller.UserController
      org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:709)
      org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:680)
      org.apache.jsp.index_jsp._jspService(index_jsp.java:62)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
  
  
  root cause 
  
  java.lang.NullPointerException
      java.util.Properties$LineReader.readLine(Properties.java:418)
      java.util.Properties.load0(Properties.java:337)
      java.util.Properties.load(Properties.java:325)
      com.pro3.util.DbUtil.getConnection(DbUtil.java:26)
      com.pro3.dao.UserDao.&lt;init&gt;(UserDao.java:19)
      com.pro3.controller.UserController.&lt;init&gt;(UserController.java:27)
      sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      java.lang.Class.newInstance0(Class.java:355)
      java.lang.Class.newInstance(Class.java:308)
      org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:709)
      org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:680)
      org.apache.jsp.index_jsp._jspService(index_jsp.java:62)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
  </code></pre>
  <p>Anyone help me out this problem.</p>
  <pre><code>public class DbUtil 
  {
      public static Connection connection = null;
      
      public static Connection getConnection()
      {
          if(connection!=null)
              return connection;
          else
          {
              try
              {
                  Properties prop=new Properties();
                  InputStream inputStream=DbUtil.class.getClassLoader().getResourceAsStream(&quot;/db.properities&quot;);
                  prop.load(inputStream);
                  
                  String driver=prop.getProperty(&quot;driver&quot;);
                  String url=prop.getProperty(&quot;url&quot;);
                  String user=prop.getProperty(&quot;user&quot;);
                  String password=prop.getProperty(&quot;password&quot;);
                  
                  Class.forName(driver);
                  connection=DriverManager.getConnection(url,user,password);
                  
              }catch(ClassNotFoundException e){
                  e.printStackTrace();
          
  </code></pre>
  <p>This is Null Pointer Exception:</p>
  <pre><code>public class UserController extends HttpServlet 
  {
      private static final long serialVersionUID = 1L;
      private static String INSERT_OR_EDIT=&quot;/user.jsp&quot;;
      private static String LIST_USER=&quot;/listuser.jsp&quot;;
      private UserDao dao;
      
      public UserController() 
      {
          super();
          dao = new UserDao();
      }
          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
          {
              String forward=&quot;&quot;;
              String action = request.getParameter(&quot;action&quot;);
              
              if(action.equalsIgnoreCase(&quot;delete&quot;))
              {
                  int userId=Integer.parseInt(request.getParameter(&quot;userid&quot;));
                  dao.deleteUser(userId);
                  forward=LIST_USER;
                  request.setAttribute(&quot;users&quot;, dao.getAllUsers());
              }
              else if(action.equalsIgnoreCase(&quot;edit&quot;))
              {
                  forward=INSERT_OR_EDIT;
                  int userId=Integer.parseInt(request.getParameter(&quot;userid&quot;));
                  User user=dao.getUserById(userId);
                  request.setAttribute(&quot;user&quot;, user);
              }
              else if(action.equalsIgnoreCase(&quot;listUser&quot;))
              {
                  forward=LIST_USER;
                  request.setAttribute(&quot;users&quot;, dao.getAllUsers());
              }
              else
              {
                  forward=INSERT_OR_EDIT;
              }
              RequestDispatcher view=request.getRequestDispatcher(forward);
              view.forward(request, response);
          }
          
          protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
          {
          User user=new User();
          user.setFirstName(request.getParameter(&quot;firstname&quot;));
          user.setLastName(request.getParameter(&quot;lastname&quot;));
         try
         {
             Date dob = new SimpleDateFormat(&quot;dd/mm/yyyy&quot;).parse(request.getParameter(&quot;dob&quot;));
             user.setDob(dob);
         }
         catch(ParseException e)
         {
             e.printStackTrace();
         }
          user.setEmail(request.getParameter(&quot;email&quot;));
          String userid=request.getParameter(&quot;userid&quot;);
          if(user==null||userid.isEmpty())    
          {
              dao.addUser(user);
          }
          else
          {
              user.setUserid(Integer.parseInt(userid));
              dao.updateUser(user);
          }
          RequestDispatcher view=request.getRequestDispatcher(LIST_USER);
          request.setAttribute(&quot;users&quot;, dao.getAllUsers());
          view.forward(request, response);
       }
  }
  </code></pre>
  <hr />
  <p>Pablo Lozano: He found some error, and then ill do it then, now i getting this kind of error.</p>
  <blockquote>
  <p>HTTP Status 500 - java.lang.NullPointerException</p>
  <p>-------------------------------------------------------------------------------- type</p>
  </blockquote>
  <p>Exception report message java.lang.NullPointerException</p>
  <blockquote>
  <p>description The server encountered an internal error that prevented it
  from fulfilling this request.</p>
  </blockquote>
  <p>exception</p>
  <blockquote>
  <p>org.apache.jasper.JasperException: java.lang.NullPointerException
  org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:502)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:723)</p>
  </blockquote>
  <p>rootcause</p>
  <p>java.lang.NullPointerException</p>
  <blockquote>
  <p>com.pro3.dao.UserDao.getAllUsers(UserDao.java:74)
  com.pro3.controller.UserController.doGet(UserController.java:51)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
  org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:709)
  org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:680)
  org.apache.jsp.index_jsp._jspService(index_jsp.java:62)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:723)</p>
  </blockquote>