Employee list with pure JSP (Model 1)

Our initial Model 1 JSP-based application consists of just one JSP file, simplicity itself. JSP file contains two clearly separated sections. One section loads employees from a storage, creates employee list to display, and stores this list in an appropriate J2EE scope, in our case in the session. Another section of the JSP file displays employee list as rows of an HTML table.

employee_list.gif

Distinct separation of data preparation code and markup rendering code helps with readability. Note JSTL 2.0 usage, it greatly simplifies the markup.

{{{<%@ page import="java.util.ArrayList, model.EmployeeManager"%> <%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%-- Load employees, build employee list, store list in the session --%>

<%

%>

<%-- Display employee list in HTML table --%>

<html>

</html>}}}

Next: converting pure JSP app into servlet/JSP app

StrutsQuickStartJSP (last edited 2009-09-20 23:12:42 by localhost)