Matt RaibleMatt Raible is a Java Champion and Developer Advocate at Okta. developer.okta.com

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

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
Comments:

Just strolling by, thought I would mention that your site does not validate. The character that messes up the XTML validator is the "&" character. Instead of referring to it as such, use "&amp;" and it should solve your problem. (Without the quotes, of course.) Sorry to be a first time visitor handing out advice.... I hate those types. :) Interesting reading. Cheers.

Posted by Bradley on November 22, 2002 at 10:05 PM MST #

Sorry, that should be "& a m p ;". I had to add a space in between each character because it rendered it as an actual &!

Posted by Bradley on November 22, 2002 at 10:07 PM MST #

Yep, this happens a lot - as anyone that maintains an XHTML Strict site will tell you. This morning issue was caused by a Velocity error rather than something I typed in though. Fixed now.

Posted by Matt Raible on November 23, 2002 at 05:53 AM MST #

Matt, you can escape the \$ and the \# by placing a slash in front of them.

Posted by Lance on November 23, 2002 at 09:51 AM MST #

Thanks Lance - this worked for the #, but apparently I didn't need to escape the $'s.

Posted by Matt Raible on November 23, 2002 at 12:05 PM MST #

Why not try eXist XML database and use XQuery to generate XHTML ?!

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 #

Post a Comment:
  • HTML Syntax: Allowed