title: Nullpointer exception at doGet and doPost methods
body: <p>This is the servlet code where I get the Nullpointer exxception.There are no objects that I need to get Initialized. What would be the problem?</p>
  
  <pre><code>package sms.controller;
  
  import sms.model.DbConnection;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.sql.Connection;
  import java.sql.Date;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  import java.util.ArrayList;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import net.sf.json.JSONArray;
  import net.sf.json.JSONObject;
  
  public class StaffManagementServlet extends HttpServlet {
  
  Connection con = null;
  Statement st = null;
  ResultSet rs = null;
  PrintWriter out;
  JSONArray jsonArray;
  JSONObject jsonObject;
  private static final long serialVersionUID = 1L;
  
  /**
   * @see HttpServlet#HttpServlet()
   */
  public StaffManagementServlet() {
      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
      doPost(request, response); //line 50
  }
  
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
   *      response)
   */
  protected void doPost(HttpServletRequest request,
          HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
  
      String action = request.getParameter("action");
      System.out.println(action+"--------");
      if (action.equalsIgnoreCase("registration")) { //line 63
          userRegistration(request, response);
      }
      if (action.equalsIgnoreCase("login")) {
          userLogin(request, response);
      }
      if (action.equalsIgnoreCase("section")) {
          getSection(request, response);
      }
      if (action.equalsIgnoreCase("question")) {
          getQuestion(request, response);
      }
      if (action.equalsIgnoreCase("semister")) {
          getSemister(request, response);
      }
      if (action.equalsIgnoreCase("branch")) {
          getBranch(request, response);
      }
      if (action.equalsIgnoreCase("forget")) {
          forgetPassword(request, response);
      }
      if (action.equalsIgnoreCase("setPass")) {
          setPassword(request, response);
      }
  
  }
  </code></pre>
  
  <p>This is the error I get when I run the sevlet on the server.</p>
  
  <pre><code>java.lang.NullPointerException
  sms.controller.StaffManagementServlet.doPost(StaffManagementServlet.java:63)
  sms.controller.StaffManagementServlet.doGet(StaffManagementServlet.java:50)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  </code></pre>