Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Velocity & JSTL

  1. #1
    Join Date
    Sep 2004
    Location
    Sydney
    Posts
    27

    Default Velocity & JSTL

    When would one prefer to use velocity over JSTL? I'm working with spring which is quite neat, so of course I want a neat solution up the front. Any suggestions or recommendations?

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default Velocity over JSTL

    I would say JSTL is easier to use. The Velocity language is trivial to learn, so learning is not an issue, it's just setting up and use og macros.

    Velocity has a performance benefit that will probably only be noticeable if rendering is a bottleneck (which it usually isn't).

    The other reason to use it is to force proper use of MVC - no chance to break into scripting code.

  3. #3
    Join Date
    Sep 2004
    Posts
    19

    Default

    We spent a little time evaluating different view technologies for an upcoming project and have settled on Velocity. We haven't actually begun work on the project yet - prototypes only - so take this with a grain of salt, but the benefits as we saw them are:

    1. REALLY enforces MVC architecture. If you really, really, really wanted to put some business logic in your templates, you probably could hack a way to do it, but for the most part it's tough, if not impossible. This is a pain in the ass at times especially when, like me, you come from an ASP or JSP background and are used to being able to do what you want to do in the page. I think you'll find, though, that after some growing pains you'll really come to appreciate the separation.

    2. The templating language is incredibly simple to learn - I'd say you'd be up and running in less than one day - and the Spring integration seems to be fairly straightforward (again, only prototypes so far...).

    3. Building on the above two strengths, the division of labor that I always hear about - one person/group working on business logic, one person/group working on UI, etc. - becomes very logical. Again, the separation of business logic and view is great.

    Good luck. I'd be happy to go into greater depth, to the extent that I'm able. Unfortunately I don't have a lot of JSTL experience, but I'm pretty sure I get the gist...

    Brian

  4. #4
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default

    Quote Originally Posted by brianstclair
    3. Building on the above two strengths, the division of labor that I always hear about - one person/group working on business logic, one person/group working on UI, etc. - becomes very logical. Again, the separation of business logic and view is great.
    hehe.

    We use Velocity in a major project for similar reasons. When the project first went live it had to be compatible with a Servlet API v2.2 so the JSP/JSTL support and performance were awful. We also picked it over FreeMarker because of the simpler syntax - like Brian, I also hoped that one day our HTML people would edit the Velocity templates so this was important too.
    Darren Davison.
    Public Key: 0xE855B3EA

  5. #5
    Join Date
    Sep 2004
    Posts
    5

    Default use freemarker

    I would highly recommend Freemarker instead. We switched from JSP to Velocity to Freemarker, and it is by far the best solution for large projects. Freemarker's site has a comparisson between it and Velocity http://freemarker.sourceforge.net/fmVsVel.html that you can check out.

    I highly recommend it though

  6. #6
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default

    I don't disagree that FM is much better (more powerful) than Velocity, but if having non-coders learn one of them from scratch, the VTL syntax tends to be much easier.
    Darren Davison.
    Public Key: 0xE855B3EA

  7. #7
    Join Date
    Sep 2004
    Posts
    5

    Default

    I know Velocity is easier to use, but Freemarker has pretty awesome documentation. Anyone (even with limited skills) could learn to use the main features of FTL with a day (probably less) by reading the docs. I think the benifits over Velocity make so many things easier in the long run that the added power makes it an obvious choice over Velocity. I would never go back to Velocity because Freemarker has too many features. The syntax is even closer to HTML, so I'd expect a web guy or gal who just knew HTML to understand it just as quick as Velocity, maybe just not all the features, but definantly the features Velocity has.

  8. #8
    Join Date
    Sep 2004
    Location
    Sydney
    Posts
    27

    Default

    Thanks for the notes. I wont' have a division of labour, the java programmers will be developing the views, so this is not a problem. I guess if the remarks about freemarker are correct, perhaps I should investigate that a bit more!
    The reason I'm not into JSP/JSTL is that I like to have tidy code, and I've done JSP's and it's just messy and awful!

  9. #9
    Join Date
    Aug 2004
    Location
    Auburn, AL, USA.
    Posts
    106

    Default

    Just one thing to mention, if you stick to with JSP-EL the pages are much cleaner; it is more limited than something like FreeMaker, but is is much more manageable than the original <% style tags.

  10. #10
    Join Date
    Sep 2004
    Location
    Sydney
    Posts
    27

    Default

    I think the other thing I'm sort of concerned about is whether there is really any active development on both of the projects. I've read that velocity has not really had any work on it for over a year, and freemarker forums on sourceforge have bugs listed and not assigned to anyone, some bugs are over 3 years old?

Similar Threads

  1. How to configure Velocity tools?
    By alr in forum Web
    Replies: 7
    Last Post: Jan 31st, 2007, 09:38 AM
  2. FreeMarker vs Velocity
    By Martin Kersten in forum Architecture
    Replies: 8
    Last Post: May 30th, 2005, 09:21 AM
  3. Velocity OutOfMemoryError during UnitTests
    By camach in forum Container
    Replies: 2
    Last Post: May 26th, 2005, 05:28 PM
  4. Using Long in velocity templates
    By paul.barry in forum Web
    Replies: 1
    Last Post: May 9th, 2005, 07:34 AM
  5. Exposing velocity context
    By masum in forum Web
    Replies: 1
    Last Post: Oct 28th, 2004, 02:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •