title: setattribute value to be fetch in jsp by getattribute but getting nullpointer
body: <p>I had tried from servlet set value by setattribute and it have to iterate in jsp by getattribute by setter and getter method without EL and JSTl but am getting this error .kindly help on this i searched in google but i cant found. </p>
  
  <pre><code>java.lang.NullPointerException
      org.apache.jsp.Home_jsp._jspService(Home_jsp.java:138)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>here serlvet code</p>
  
  <pre><code>    package servlet2;
  
  import java.io.IOException;
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.util.ArrayList;
  import java.util.TreeSet;
  
  import javafx.css.PseudoClass;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import servlet.Dao;
  import jdbc.jdbcconnection;
  
  /**
   * Servlet implementation class Homepage
   */
  //@WebServlet(asyncSupported = true, urlPatterns = { "/Homepage" })
  public class Homepage extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      /**
       * @see HttpServlet#HttpServlet()
       */
      public Homepage() {
          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
  
          System.out.println("inside==========&gt;");
  
          String name=request.getParameter("name");
          String password=request.getParameter("password");
          String phone=request.getParameter("Phone");
          String Deptmart=request.getParameter("Dep");
          String gender=request.getParameter("gender");
          String country=request.getParameter("country");
  
          Dao d=new Dao();
  
          try
          {
          jdbcconnection jc=new jdbcconnection();
  
          Connection con=jc.getconnection();
  
          String sql="insert into homepage(name,password,phone,Dept,gender,Country) values(?,?,?,?,?,?)";
  
              PreparedStatement ps=con.prepareStatement(sql);
  
              ps.setString(1, name);
              ps.setString(2, password);
              ps.setString(3, phone);
              ps.setString(4, Deptmart);
              ps.setString(5, gender);
              ps.setString(6, country);
  
              System.out.println("ps=========&gt;"+ps);
  
              ps.execute();
  
              con.commit();
  
  
              String select="select * from homepage";
  
              PreparedStatement ps1=con.prepareStatement(select);
  
              ResultSet rs=ps.executeQuery();
  
              ArrayList t=new ArrayList();
              while(rs.next())
              {
                  d.setid(rs.getInt(1));
                  d.setName(rs.getString(2));
                  d.setPassword(rs.getString(3));
                  d.setPhone(rs.getInt(4));
                  d.setDeptmart(rs.getString(5));
                  d.setGender(rs.getString(6));
                  d.setCountry(rs.getString(7));
  
                  t.add(d);
              }
  
              request.setAttribute("users",t);
  
              RequestDispatcher rs1=request.getRequestDispatcher("/Home.jsp");
              rs1.forward(request, response);
                  }
  
          catch (SQLException | ClassNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
  
  
      }
  
      /**
       * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
       */
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
      }
  
  }
  </code></pre>
  
  <p>Jsp page:</p>
  
  
  
  <pre><code>&lt;%@page import="servlet.Dao,java.util.*" %&gt;
  
  
  
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="Homepage" method="get"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;Name:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="name" id="name"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Password:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="password" id="password"&gt;&lt;/td&gt;
          &lt;tr&gt;
              &lt;td&gt;Phone:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="Phone" id="Phone"&gt;
          &lt;/tr&gt;
          &lt;/td&gt;
          &lt;tr&gt;
              &lt;td&gt;Department:&lt;/td&gt;
              &lt;td&gt;&lt;select id="Dep" name="Dep"&gt;
                      &lt;option value="it"&gt;IT&lt;/option&gt;
                      &lt;option value="finace"&gt;Finace&lt;/option&gt;
                      &lt;option value="market"&gt;Marketing&lt;/option&gt;
              &lt;/select&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Gender:&lt;/td&gt;
              &lt;td&gt;&lt;input type="radio" name="gender" id="gender" Value="Male"&gt;Male
                  &lt;input type="radio" name="gender" id="gender" Value="Female"&gt;Female&lt;/td&gt;
          &lt;/tr&gt;
  
  
          &lt;tr&gt;
              &lt;td&gt;Country:&lt;/td&gt;
              &lt;td&gt;&lt;input type="checkbox" name="country" id="country"
                  Value="India"&gt;India &lt;input type="checkbox" name="country"
                  id="country" Value="Other"&gt;Other&lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;br&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="submit" name="Add" Value="ADD" &gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="button" name="Clear" Value="CLEAR"&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  
  &lt;table border="1"&gt;
  
  &lt;tr&gt;&lt;td&gt;Id&lt;/td&gt;&lt;td&gt;name&lt;/td&gt;
  &lt;td&gt;Password&lt;/td&gt;
  &lt;td&gt;Phone&lt;/td&gt;
  &lt;td&gt;Deptmart&lt;/td&gt;
  &lt;td&gt;Gender&lt;/td&gt;
  &lt;td&gt;country&lt;/td&gt;
  &lt;td&gt;Edit&lt;/td&gt;
  &lt;td&gt;Delete&lt;/td&gt;
  &lt;/tr&gt;
  
   &lt;%
   try
   {
          List&lt;Dao&gt; al1 = (List) request.getAttribute("users");
        //  System.out.println(al1); // prints null
          for(Dao user : al1) {
  
  
  
          %&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;%=user.getid() %&gt;&lt;/td&gt;
  
  &lt;td&gt;&lt;%=user.getName() %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%=user.getPassword() %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%=user.getPhone() %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%=user.getDeptmart() %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%=user.getGender() %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;%=user.getCountry() %&gt;&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;%} }
  
   catch(Exception e)
   {
      e.printStackTrace();  
   }
  %&gt;
  
  
  
  
  &lt;/table&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;Homepage&lt;/servlet-name&gt;
      &lt;servlet-class&gt;servlet2.Homepage&lt;/servlet-class&gt;
    &lt;/servlet&gt;
  
  
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Homepage&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/Homepage&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  </code></pre>