0

I'm getting a null pointer exception pointing to the line containing
dispatcher.forward(request,response);
Any suggestions as to where i have gone wrong. it wud be of gr8 help...
thanks in advance:)

ArrayList empList =EmployeeDao.getEmpDetail();//this is defined already
   
      request.setAttribute("empList",empList);
   
      RequestDispatcher disp = request.getRequestDispatcher("/myPage.jsp")
      
      disp.forward(request,response);
ArrayList employeeList=null;
   
      ArrayList employeeList=(ArrayList)request.getAttribute("empList");
   
     
   
     
      if(!employeeList.isEmpty())
   
      {
   
      for(int i=0;i<employeeList.size();i++)
   
      {
   
      %>
  
       
  
      <tr>
  
      <Td><%=employeeList.get(0)%></Td>
  
      <Td><%=newslist.get(1)%></Td>
  
      </tr>
  
      <%
  
      }
  
      }
  
      %>

Edited by screenedcreamy: insufficient data

3
Contributors
7
Replies
9
Views
7 Years
Discussion Span
Last Post by deepadinnu
0

Are you sure that ArrayList empList =EmployeeDao.getEmpDetail();//this is defined already doesn't return null value?

0

i too had the same doubt..
so just after ArrayList empList =EmployeeDao.getEmpDetail();
i inserted

for(int i=0;i<al.size();i++){
System.Out.Println((Employee)al.get(i)).getName());
System.Out.Println((Employee)al.get(i)).getEmpID());
}

i got desiered o/p there name n the ID was displayed
thers smthing else causing the trouble not able to figure out

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

0

HTTP Status 500
java.lang.NullPointerException
EmployeeInfo.doPost(EmployeeInfo.java:8)
and line 8 refers to -

disp.forward(request,response);
0

Problem Solved. A silly mistake request was supposed to go to a file named mypage.jsp(original file with the content) in my webapps and the request was going to myPage.jsp which had nothing in it . Thank you so much for your time and suggestions.:)

0
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class NetServlet extends HttpServlet
{
    public void doGet(HttpServletRequest request43,HttpServletResponse response43)throws IOException
    {
        float gross=(Float)request43.getAttribute("dpa");
        float deductions=gross*0.06f;
        float net=gross-deductions;
        response43.setContentType("text/html");
        PrintWriter out=response43.getWriter();
        out.println("<html>");
        out.println("<body bgcolor=skyblue>");
        out.println("<h1>take home salary is Rs:"+net+"<h1>");
        out.println("<body>");
        out.println("</html>");
        out.close();


    }
}

i

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.