I l @ ve RuBoard |
After building and compiling the Employee bean, you can test it with some standalone JSP pages. To begin, see if you can read employee records out of the database (see Listing 15.4). The test program takes an employee user ID as an argument and then uses the findEmployee method to look it up in LDAP. If an employee is found and returned, the code displays various pieces of information about that person (see Figure 15.5); otherwise it prints an error message. Figure 15.5. Running testLdapRead.jsp.
Listing 15.4 testLdapRead.jsp<%@ page import="com.bfg.employee.Employee" %> <HEAD><TITLE>Look for employee test</TITLE></HEAD><BODY> <% Employee emp = Employee.findEmployee(request.getParameter("uid")); if (emp != null) { %> Found employee <%= emp.getFirstName() %> <%= emp.getLastName() %>!<P> First Name: <%= emp.getFirstName() %><BR> Last Name: <%= emp.getLastName() %><BR> Password: <%= emp.getPassword() %><BR> Title: <%= emp.getTitle() %><BR> Employee Num: <%= emp.getEmployeeNumber() %><BR> Telephone: <%= emp.getTelephoneNumber() %><P> <% } else { %> Employee not found! <% } %> </BODY> |
I l @ ve RuBoard |