Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp, velocity, freemarker etc.

 
pete reisinger
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm sure this topic was here before, but I just want some new opinions.
I'm quite new to Java/servelts/jsp etc. so I want to ask why should I use freemarker or velocity instead of jsp.
as far as i understand, velocity and freemarker force developers not to use java code in them, but if I create nice
jsp without java code in them (scriptless), then why wouldn't I use them? they tend to be faster, more people know them
(so there's no learning curve), configuration is minimal etc.
As you can see I see only pros of jsp, but I'm not able to find pros of velocity or freemarker (except of not using java code, but the same can be done by jsp).
Are there any advantages of using different technologies than jsp?
Thanks.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSPs have the advantage that you can use JSTL and other tag libraries in them (of which there are quite a few nice ones, such as DisplayTag for highly functional tables, cewolf for embedded charts etc.).

The non-JSP templating libraries have the advantage of not requiring a servlet container environment, so if you're familiar with them you can leverage that knowledge elsewhere (and you're likely to need such a library outside of a servlet environment at some point). On the other hand, they're fairly easy to get started with, so that's not saving you a big learning curve.

IMO, JSPs are such an entrenched and functional standard that I haven't encountered a good reason why one wouldn't use them for a new project.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pete reisinger wrote:so I want to ask why should I use freemarker or velocity instead of jsp.
You shouldn't. There, that was easy.

These technologies precede JSP 2.0, and post-2.0, at least in my opinion, have no advantage over JSP 2.0 for creating the views of web apps.

They do, however, still have use as templating engines for uses other than web views (formatting emails bodies, for example).
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Web: JSP is like crack for people that like to type. I believe FreeMarker/Velocity/etc. are cleaner than the JSP alternative. JSP has *substantially* wider adoption. Tool support is *excellent*, due precisely to the reason it's verbose (solvable issue, but low ROI).

(I don't know how other frameworks support template engines, but in Struts 2 we can use third-party tag libraries withing FreeMarker templates. At one point I thought support was limited to non-JSP-based tags, but that may have changed or I might just be wrong.)

The Rest: I know you *can* run JSP outside of the container with minor treachery, but yick--if I'm doing almost anything that doesn't require existing custom tags and its structure is never required, I'll use a template engine every single time before I'd use JSP.

Most of these engines have a way of writing macros/etc. to allow re-use of chunks, so it's possible to refactor the templates if the application benefits from re-use (like a web app, but also things like reports, partially-customized mailings of various types, etc.).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic