|It is solved. Class was in default package. I put it in a package and import that
Package.Class in JSP. works like a charm.
Hello there. I am attaching two variables with a
HttpServletRequest request, an integer and an arraylist. After this when I forward request to a JSP, these casting issues arise. Here is the java servlet code
ArrayList<Employee> list_employees = m_objDbLayer.GetEmployeesAll();
int employee_count = list_employees.size();
RequestDispatcher dispatcher = request.getRequestDispatcher("/ViewEmployeesPage.jsp");
And here is the JSP code where I access these variables
<%@page import="/WEB-INF/classes/Employee" %>
<!-- all the starting HTML tags here-->
int employee_count= (int)request.getAttribute("employee_count");
out.println("Total Employees: " + employee_count);
ArrayList<Employee> list_users =new ArrayList<Employee>();
list_users = (ArrayList<Employee>)request.getAttribute("list_employees");
I get these exceptions in server log
1- Cannot cast from Object to int<br />
2- Employee cannot be resolved to a type<br />
As you can see I am importing Employee class in JSP, what is wrong? Why it can not resolve Employee and convert from object to int? Thanks for any input.
modified 26-Aug-16 6:32am.