Java Reference
In-Depth Information
L ISTING 11.4
Continued
throw new ServletException(ex);
}
// output the results
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println(“<html>”);
out.println(“<head><title>LDAPTestServlet</title></head>”);
out.println(“<body>”);
out.println(“<p>The search results are:</p>”);
Iterator iter = results.iterator();
while (iter.hasNext()) {
LDAPObject lobj = (LDAPObject)iter.next();
out.println(lobj.getDn());
out.println(“cn: “ + lobj.getAttribute(“cn”) + “<br>”);
out.println(“sn: “ + lobj.getAttribute(“sn”) + “<br>”);
out.println(“givenName: “ + lobj.getAttribute(“sn”) + “<br>”);
out.println(“mail: “ + lobj.getAttribute(“mail”) + “<br>”);
out.println(“telephoneNumber: “
+ lobj.getAttribute(“telephoneNumber”) + “<br>”);
out.println(“<br>&nbsp;<br>”);
}
out.println(“</body></html>”);
}
/**Clean up resources*/
public void destroy() {
}
}
Summary
LDAP provides an alternative method of persistent storage. It is well suited for systems that
require a high volume of read operations combined with a limited number of modifications.
The data is represented in a tree-like hierarchy and consists of objects containing name-value
pairs. Java provides an API to access LDAP servers called Java Naming and Directory
Interface (JNDI). JNDI makes accessing LDAP servers simple, and it is a good choice for
many systems.
In the next chapter we are going to discuss Enterprise JavaBeans and how they can be lever-
aged to encapsulate Web application business logic.
 
Search WWH ::




Custom Search