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
- Happy Birthday Jack!
- A Good Friend becomes a DU Hockey Coach
- What's wrong with JSF
- Why such a busy week?
- New Passport in 9 Days
- EhCache Project Busy this Summer
- Spontaneous Stuff Weekend
- Awesome Birthday Present: A Kegerator
- Maven Plugin for Running Integration Tests against Multiple Containers
- Presenting Web Frameworks of the Future Tomorrow in Denver
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 #