Differences between revisions 4 and 5
Revision 4 as of 2007-02-21 01:50:16
Size: 1528
Editor: 64-160-69-34
Revision 5 as of 2009-09-20 23:12:42
Size: 1537
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
inline:employee_list.gif {{attachment:employee_list.gif}}
Line 43: Line 43:
[:StrutsQuickStartServletJSP:Next: converting pure JSP app into servlet/JSP app] [[StrutsQuickStartServletJSP|Next: converting pure JSP app into servlet/JSP app]]

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.


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 --%>


  • if (session.getAttribute("employees") == null) { }


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


  • <body>

    • <table>

      • <tr>

        • <th align="left">Emp #</th> <th align="left">Name</th> <th align="left">Salary</th>

        </tr> <c:forEach var="employee" items="${employees}">

        • <tr>

          • <td>${employee.id}</td> <td>${employee.name}</td> <td>${employee.salary}</td>






Next: converting pure JSP app into servlet/JSP app

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