JSTL in Action http://www.manning.com/bayern/ Rick DeBay
On Fri, 27 Feb 2004 13:45 , A.White <[EMAIL PROTECTED]> sent: >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 [EMAIL PROTECTED]','','','')">[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 [EMAIL PROTECTED]','','','')">[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 >//) 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 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: >=== > > bgcolor="white"> > > > Topic: ${meeting.topic} > > >var="event"> > >value="${meeting.participation[event.fromId]}" /> > > >'fqcn.URLPushedEvent'}"> > > > >value="${yapper.participantId}" /> > >color="#000000">${yapper.name}: > > > >color="#0000f0">${yapper.name}: > > > >href="${event.storedData}">"${event.storedData}" > > >'fqcn.ChatEvent'}"> > > > >color="#000000">${yapper.name}: > >value="${yapper.participantId}" /> > > > >color="#0000f0">${yapper.name}: > > > >href="${event.storedData}">"${event.storedData}" > > > > > ${meeting.meetingId}:${repId} > > > >=== >The velocity version: >=== > > bgcolor="white"> > > > Topic: $meeting.getTopic() > > #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() ) > >color="$blk">$yapper.getName() > > #else > >color="$blu">$yapper.getName() > #end > > >href="$event.getStoredData()">$event.getStoredData() > > #elseif( $event.getClass().getName().equals($chatEvent) ) > > #if($repRole.equals($yapper.getRole()) ) > #set( $repId = $yapper.getParticipantId() ) > >color="$blk">$yapper.getName() > > #else > >color="$blu">$yapper.getName() > #end > > $event.getStoredData() > #end > > #end > > $meeting.getMeetingId():$repId > > > >=== > >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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]