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?
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.
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.).