struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Struts Wiki] Trivial Update of "StrutsQuickStartJSP" by MichaelJouravlev
Date Wed, 21 Feb 2007 01:50:18 GMT
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:

  == 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.
- 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.
+ 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 data from the storage --%>
+ <%-- Load employees, build employee list, store list in the session --%>
      if (session.getAttribute("employees") == null) {
@@ -17, +19 @@

- <%-- Display data --%>
+ <%-- Display employee list in HTML table --%>
          <th align="left">Emp #</th>
@@ -39, +42 @@

+ [:StrutsQuickStartServletJSP:Next: converting pure JSP app into servlet/JSP app]

View raw message