Thanks for your answers, they are all greatly appreciated

I think I'll be using JSP and JTSL then.  However I have tried to look
for some good tutorials for JTSL but have failed to find any that have
addressed the basics.  

Any pointers to resources (apart from www.google.com ;-) ) will receive
huge karma and gratitude in their next life

Andrew



-----Original Message-----
From: Andrew Hill [mailto:[EMAIL PROTECTED] 
Sent: 27 February 2004 13:35
To: Struts Users Mailing List
Subject: RE: [OT] JSP or Velocity


Yes, Velocity has been around for quite awhile now, and it was intended
to address many of the problems inherent in (older versions of) JSP.

Nowdays JSP (especially JSP2) coding techniques and technologies have
rather caught up with velocity. Your assesment that it doesnt add much
value over the EL capabilities in JSP2 is pretty much on the mark. Of
course it wasnt always this way and for a long time velocity was much
nicer. (Still looks nicer ;->)

I reckon you are also correct in believing that velocity design provided
a lot of the inspiration for the jstl stuff.

-----Original Message-----
From: Larry Meadors [mailto:[EMAIL PROTECTED]
Sent: Friday, 27 February 2004 21:26
To: [EMAIL PROTECTED]
Subject: Re: [OT] JSP or Velocity


>>> [EMAIL PROTECTED] 02/27/04 5:44 AM >>>
> I am starting to develop an application using struts and have been 
> looking round the rest of the Jakarta project and came across the 
> Velocity project.
>
> I was interested to see which which people recommended for a relative 
> newbie

After looking at velocity, I am certainly of the opinion that it adds no
value over jsp2/jstl. It offers absolutely nothing that the jsp2/jstl
combination does not. The only difference is that velocity is a bit more
terse (if/else/end instead of
<c:choose>/<c:when>/<c:otherwise>) and that it uses # instead of the <>.

It is important to note that I am talking about jsp2 and tomcat 5, not
the jsp1 in tomcat 4.

A while back I looked in detail at the jsp/velocity comparison on the
velocity site.

There are several issues with the comparison. The person writing the
case study was cleary biased towards velocity and had never even
considered JSTL (which in all fairness may not have been available at
that time). Looking at the code (both the velocity and jstl versions are
below) I think that velocity clearly had an influence on the jsp2/jstl
constructs.

The first thing I noticed was that the two pages do not do the same
thing. The jsp turns off the session (the vm does not). The jsp stores
variables that are never used which were factored out in the vm version.
The vm version

is missing required code (for example, the repCode and urlEvent
variables are never defined).

The jsp page is also *very* poorly written using scriptlets. You should
rarely need to use scriptlets in jsp1/jstl pages, and I suspect with
jsp2/jstl, you will not ever
*need* to.

With struts, you do not need to use <jsp:useBean> tags either because
the controller does that for you.

The jsp2/jstl version is a bit more verbose because it is based on xml
so you cannot have things like if/else/end because they are unbalanced,
but other than that, there are no significant differences.

After converting the page to use JSTL and eliminating ALL of the <% %>
stuff, we get something more like this:

===
The JSP version:
===
<table width="600" border="0" cellspacing="0" cellpadding="4"
   bgcolor="white">
   <tr>
       <td>
           <i><b>Topic: ${meeting.topic}</b></i>

           <c:forEach list="${meeting.storedEventsIterator}"
var="event">
               <c:set var="yapper"
value="${meeting.participation[event.fromId]}" />
               <c:choose>
                   <c:when test="${event.class.name eq
'fqcn.URLPushedEvent'}">
                       <c:choose>
                           <c:when test="${yapper.role eq 'R'}">
                               <c:set var="repId"
value="${yapper.participantId}" />
                               <font
color="#000000"><b>${yapper.name}:</b></font>
                           </c:when>
                           <c:otherwise>
                               <font
color="#0000f0"><b>${yapper.name}:</b></font>
                           </c:otherwise>
                       </c:choose>
                       <a
href="${event.storedData}">"${event.storedData}"</a> <br>
                   </c:when>
                   <c:when test="${event.class.name eq
'fqcn.ChatEvent'}">
                       <c:choose>
                           <c:when test="${yapper.role eq 'R'}">
                               <font
color="#000000"><b>${yapper.name}:</b></font>
                               <c:set var="repId"
value="${yapper.participantId}" />
                           </c:when>
                           <c:otherwise>
                               <font
color="#0000f0"><b>${yapper.name}:</b></font>
                           </c:otherwise>
                       </c:choose>
                       <a
href="${event.storedData}">"${event.storedData}"</a> <br>
                   </c:when>
               </c:choose>
           </c:forEach>
           <hr>
           <br>${meeting.meetingId}:${repId}<br>
       </td>
   </tr>
</table>
===
The velocity version:
===
<table width="600" border="0" cellspacing="0" cellpadding="4"
   bgcolor="white">
   <tr>
       <td>
           <i><b>Topic: $meeting.getTopic()</b></i><p>

           #foreach( $event in $meeting.getStoredEventsIterator() )
               #set( $yapper =
$meeting.getParticipation($event.getFromId()) )

               #if( $event.getClass().getName().equals($urlEvent) )

                   #if( $repRole.equals($yapper.getRole()) )
                       #set( $repId = $yapper.getParticipantId() )
                       <font
color="$blk"><b>$yapper.getName()</b></font>

                   #else
                       <font
color="$blu"><b>$yapper.getName()</b></font>
                   #end

                   <a
href="$event.getStoredData()">$event.getStoredData()</a> <br>

               #elseif( $event.getClass().getName().equals($chatEvent) )

                   #if($repRole.equals($yapper.getRole()) )
                       #set( $repId = $yapper.getParticipantId() )
                       <font
color="$blk"><b>$yapper.getName()</b></font>

                   #else
                       <font
color="$blu"><b>$yapper.getName()</b></font>
                   #end

                   $event.getStoredData() <br>
               #end

           #end
           <hr>
           <br>$meeting.getMeetingId():$repId<br>
       </td>
   </tr>
</table>
===

Larry


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to