Friday November 22, 2002
JSP's Evolution There's another interesting discussion taking place over on the struts-dev list again. Man, I'm glad I subscribed (again) to this list last week! It started out as a discussion of JSP vs. Velocity and Craig (McClanahan) provided an interesting evolution of JSP (and comparison to Velocity).
Velocity:
========
(Note -- it's assumed that the Customer collection has been stored in the
VelocityContext by some preceding business logic.)
\#foreach $result in $results {
<tr>
<td>$result.ID</td>
<td>$result.Name</td>
</tr>
}
JSP 1.1 (with Scriptlets):
=========================
<%
Customer custs = ...;
for (int i=0; i < custs.length; i++) {
%>
<tr>
<td><%= custs[i].getId() %></td>
<td><%= custs[i].getName() %></td>
</tr>
<%
}
%>
JSP 1.1 (with custom tags):
==========================
(Note -- it is assumed here and in the following examples that the
Customer collection has been stored by some preceding business logic.)
<logic:iterate id="cust" name="custs">
<tr>
<td><jsp:getProperty name="cust" property="id"/></td>
<td><jsp:getProperty name="cust" property="name"/></td>
</tr>
</logic:iterate>
JSP 1.2 + JSTL 1.0:
==================
<c:forEach var="cust" items="${custs}">
<tr>
<td><c:out value="${cust.id}"/></td>
<td><c:out value="${cust.name}"/></td>
</tr>
</c:forEach>
JSP 2.0 + JSTL 1.0:
==================
<c:forEach var="cust" items="${custs}">
<tr>
<td>${cust.id}</td>
<td>${cust.name}</td>
</tr>
</c:forEach>
</pre>
I can't wait for JSP 2.0 - it's going to make everything so much easier. Once again, we have exciting times for the Java world. With the power of JSP 2.0 and XDoclet, deadlines should be a non-issue. Now we just have to figure out the best way to use them, and the fastest way to pump out a Struts project. Wouldn't it be awesome if you you could add a new column to a table, build your project using Ant and XDoclet and whalla, all your classes are updated! That would be cool - and I think it's possible. Now I just have to figure out how - and fast! Posted in Java at Nov 22 2002, 06:05:23 PM MST 6 Comments
Search This Site
Recent Entries
- Raible Road Trip #13
- The good ol' Job Hunt
- How to use GWT 2.0 with Maven and Generate SOYC Reports
- JSON Parsing with JavaScript Overlay Types in GWT
- A Fun Father's Day at Great Sand Dunes
- Going to the Great Sand Dunes for Father's Day
- Implementing OAuth with GWT
- Enhancing Evite.com with GWT and Grails
- 2nd Row at Red Rocks and Elephant Rock Ride
- Creating a Facebook-style Autocomplete with GWT
Posted by Bradley on November 22, 2002 at 09:05 PM MST #
Posted by Bradley on November 22, 2002 at 09:07 PM MST #
Posted by Matt Raible on November 23, 2002 at 04:53 AM MST #
Posted by Lance on November 23, 2002 at 08:51 AM MST #
Posted by Matt Raible on November 23, 2002 at 11:05 AM MST #
for $cust in $custs return <tr> <td>{data($cust/id)}</td> <td>{data($cust/name)}</td> </tr>This way you just stay within the XML domain. We build our entire web application using XForms, Orbeon, XQuery (eXis) this way. No XML databinding needed here !Posted by Roger van de Kimmenade on March 17, 2008 at 01:07 PM MDT #