You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by Apache Wiki <wi...@apache.org> on 2007/02/21 01:27:05 UTC

[Struts Wiki] Update of "StrutsQuickStartJSP" by MichaelJouravlev

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change notification.

The following page has been changed by MichaelJouravlev:
http://wiki.apache.org/struts/StrutsQuickStartJSP

New page:
== Employee list with pure JSP (Model 1) ==

Before the data list is displayed, it should be retrieved from a database and saved into appropriate J2EE scope like request, session or application. Then the list is iterated and its content is shown line by line. Notice JSTL 2.0 usage.

inline:employee_list.gif

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

<%-- Load data from the storage --%>

<%
    if (session.getAttribute("employees") == null) {
        session.setAttribute("employees", EmployeeManager.loadEmployees());
    }
%>

<%-- Display data --%>

<html>
  <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>
        </tr>
      </c:forEach>
    </table>

  </body>
</html>}}}