Announcement Announcement Module
Collapse
No announcement yet.
Velocity & JSTL Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment


          • #6
            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.

            Comment


            • #7
              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.

              Comment


              • #8
                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!

                Comment


                • #9
                  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.

                  Comment


                  • #10
                    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?

                    Comment


                    • #11
                      Development on Velocity recently picked up slightly, but there's talk on the FreeMarker lists of development slowing right down. It looks like 2 of 3 main FM contributors are leaving the project (or already have).

                      The problem is that there's not really anywhere for either technology to go now. They were created to do a single job (templating) and pretty much do it well. I don't know what the status of the FM bugs are - it's likely that the developers don't even use the SF facilities (just as Spring uses JIRA which is way superior).

                      Regards,

                      Comment


                      • #12
                        Another reason for using JSP/JSTL is you can validate most presentation code as XML compliant (using JSP XML syntax).

                        Comment

                        Working...
                        X