title: Null Pointer Exception after button click in servlet
body: <p>I am just passing control from jsp to Servlet using button.
  But I am getting <code>NullPointerException</code> in servlet at the lines commented, when i click submit button. Please tell me the Error.<br>
  Thanx in advance.</p>
  
  <p>This is my Jsp code</p>
  
  <pre><code>&lt;form action="JQGridServlet"&gt;
      &lt;input type="submit" name="submit" value="submit"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is my Servlet Code</p>
  
  <pre class="lang-java prettyprint-override"><code> public class JQGridServlet extends HttpServlet 
   {
    protected void processRequest(HttpServletRequest request, HttpServletResponse               
  
   response) throws Exception {        
      PrintWriter out = response.getWriter();
      IPConverter conv=new IPConverter();
  
  
      System.setProperty("log4j.defaultInitOverride","true");
      LogManager.resetConfiguration();
      LogManager.getRootLogger().addAppender(new NullAppender());
  
        try {
  
     //Null  Exception at this line            
  
          if (request.getParameter("action").equals("fetchData"))     ///////Exception
          {
              response.setContentType("text/xml;charset=UTF-8");                
  
  
              Object o = request.getAttribute("page");
              System.out.println("----------------------o="+o);
              String status = request.getParameter("status");
  
              String rows = request.getParameter("rows");
              String page = request.getParameter("page");
              if(request.getParameter("submit")!=null)
              {
              System.out.println(request.getParameter("submit"));
              }
              //  String KeyName=request.getParameter("KeyName");
              //System.out.println(KeyName);
              int totalPages = 0;
              int totalCount = 58000;
  
              if (totalCount &gt; 0) {
                  if (totalCount % Integer.parseInt(rows) == 0) {
                      totalPages = totalCount / Integer.parseInt(rows);
                  } else {
                      totalPages = (totalCount + Integer.parseInt(rows) - 1) /     
  
                Integer.parseInt(rows);
                  }
  
              } else {
                  totalPages = 0;
              }
  
              out.print("&lt;?xml version='1.0' encoding='utf-8'?&gt;\n");
              out.print("&lt;rows&gt;");
              out.print("&lt;page&gt;" + request.getParameter("page") + "&lt;/page&gt;");
  
              out.print("&lt;total&gt;" + totalPages + "&lt;/total&gt;");
              out.print("&lt;records&gt;" + 58000 + "&lt;/records&gt;");
  
              EventQuery eq=new EventQuery();
              int firstRecord = (Integer.parseInt(page) - 1)  
      *Integer.parseInt(rows);
              int lastRecord = Math.min(firstRecord + Integer.parseInt(rows), totalCount);
              List&lt;ColumnSlice&lt;String, Long&gt;&gt; row=eq.query(Integer.parseInt(request.getParameter("page")),Integer.parseInt(rows));
  
              for (int i=firstRecord,j=0;i&lt;lastRecord;i++,j++) {
  
                  out.print("&lt;row id='" + i + "'&gt;");
                  out.print("&lt;cell&gt;" + (i+1) + "&lt;/cell&gt;");
                  out.print("&lt;cell&gt;" + row.get(j).getColumnByName("USERIDEN").getValue() +"&lt;/cell&gt;");
                   out.print("&lt;cell&gt;" + conv.convert(row.get(j).getColumnByName("SOURCEIP").getValue()) +"&lt;/cell&gt;");
  
                  out.print("&lt;cell&gt;" + row.get(j).getColumnByName("BYTESENT").getValue()+"&lt;/cell&gt;");
                  out.print("&lt;cell&gt;" + row.get(j).getColumnByName("BYTERECV").getValue()+"&lt;/cell&gt;");
                  //out.print("&lt;cell&gt;&lt;![CDATA[&lt;a href='ViewStd.jsp'&gt;View&lt;/a&gt;]]&gt;&lt;/cell&gt;");
                  out.print("&lt;/row&gt;");
                  //srNo++;                
              }
              out.print("&lt;/rows&gt;");
          }
  
      } 
        catch(Exception e)
        {
            e.printStackTrace();  
        }
        finally {
          out.close();
      }
  } 
  
  
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
      try {
          processRequest(request, response);                 ///////Exception
         } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  } 
  
  
  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
      try {
          processRequest(request, response);
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }
  
  
  @Override
  public String getServletInfo() {
      return "Short description";
  }
  
   }
  </code></pre>