You do not have to do any declarations (of the <%! %> type) to do what you
want to do.

You would probably have to import the Employee class, is all.  If Employee
lived in a package com.mycom, just do <%@ page import="com.mycom.Employee"
%>

I personally never use the JavaBean framework, e.g. jsp:useBean,
jsp:whatever.  I just use scriptlets.

My Employee class's interface would probably look something like this:

public class Employee
{
  public static Employee[] getAllEmployees() { ... }
  public static Employee getEmployee(int id) { ... }
  public static Employee createEmployee(String firstname, ...) { ... }

  private Employee(int id, String firstName, ...) { ... }

  public int getId() { ... }

  public void setFirstName(String firstName) { ... }
  public String getFirstName() { ... }
  ...
}

Note that this is not a JavaBean, and you probably wouldn't write the class
this way if you intended to turn it into a JavaBean.  (Hopefully someone
else can point out the differences.)

Anyway, your servlet:

request.setAttribute("employees", com.mycom.Employee.getAllEmployees());
request.getRequestDispatcher("path_to_jsp").forward(request, response);

your JSP:
<%@ page import="com.mycom.Employee" %>
Employee[] employees = (Employee[])request.getAttribute("employees");

-jmc

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to