Hi, I am a newbie to
JSP and am having difficulty acessing an object in JSP. What I am trying to do is this - I have a JSP page with a form and on submitting it a
servlet is called. The servlet using the parameters passed creates a SQL query and calls
java method which connects to the db and retrieves the required employee records into a ResultSet. I create an employee object and populate the attributes with the row values. and put each employee object into a linked list and return it to the calling servlet.
I then pass this back to a a JSP page for display. When i try to retrieve the values from the employee object i am getting a message - Symbol nor resolved - Basically the JSP does not recognise my employee object. I would appreciate some help with this. cheers.
Also would appreciate if you could let me know if i am doing anything wrong with the following bits of code:
I am using the code shown below in the java class to popluate the linkedlist with employee object -
...
public static List list = new LinkedList();
...
results = stmt.executeQuery();
if (dataType == "Employee")
{
while(results.next())
{
Employee employee = new Employee(results.getString("EmployeeTitle"),
results.getString("EmployeeSurname"));
list.add(employee);
}
}
I am using the following bit of code to send the linkedlist to JSP page:
request.setAttribute("employees", list);
I am using the following bit of code in JSP page where i am trying to display the records in linkedlist
<%@ page import= "HousingManger.Employee" %>
...
<%
List employees = (List) request.getAttribute("employees");
ListIterator listX = employees.listIterator();
while(listX.hasNext())
{
Employee emp =new Employee();
emp = listX.next();
String varEmployeeSurname = emp.getEmployeeTitle();
String varEmployeeTitle = emp.EmployeeSurname();
out.println("<table><tr><td>" + varEmployeeSurname + "</td><td>" + varEmployeeTitle + "</td></tr></table>");
}
%>
...