Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

JSP is an archaic template language. I'm on a project with JSP on the front end; compared to Django, Jinja, or any of the other Python template languages it's really limited and verbose.

It's interesting that LinkedIn chose dust.js as it doesn't get much attention compared to some of the other JS template languages (e.g. Mustache & Handlebars.js).



I wonder what's the best alternative for server-side template generation on the JVM.

I used FreeMarker on a previous project, it's pretty cool ( http://freemarker.sourceforge.net/ ). There is also mustache.java ( https://github.com/spullara/mustache.java ). I heard about Velocity and StringTemplate, but never tried them out... I guess Groovy Server Pages could also be considered if one's company is open to Grails...

Anything else I should be aware of?


If you need pure Speed + compile-time checked Typesafe, then Japid is the nr.1. Very popular under Play! Framework community. The performance is superior, 2x - 3x better than FreeMarker.


Are you using some old version of JSP? Not unlike many other mature technologies, many times people are just victims of some arbitrary corporate standard and not the tech itself.

As far as limited, I looked at Django strictly for it's vaunted templating prowess and didn't see anything that isn't easily reproducible in JSP. There could be some magic there but I missed it.

For verbosity, sure, fn:toLowerCase(string) is technically more verbose than string|lower, but marginally so.


Version 2.0 (current version is 2.1). Apparently upgrading is not trivial (due to Spring framework or whatever... I don't know, I'm not familiar with the Java stack).

You mention an example where JSP fares best; there are a lot of examples that don't come out looking too great though, such as time/date/decimal conversion, the obnoxious syntax for if/else, etc. A lot of Django's other filters just don't exist in JSP.

But that aside, there are larger scale issues -- composition of templates via blocks in Django/Jinja, which is a lot easier and more flexible than Apache tiles; the lack of auto-escaping in JSP; and the forced XML syntax, even at the expense of valid HTML (see what it does to script includes or empty divs, without a <!-- --> in between).


Do keep in mind that LinkedIn was founded in 2003, before many of the web frameworks were released. LinkedIn also uses a custom JSP compiler, as at the time the official implementation lacked many feature.


That wasn't meant as a criticism of LinkedIn's adoption of it, more my own circumstances and the fact that frameworks are still using JSP by default in 2011.


Definitely wouldn't use it. Even for server-side Java, there are better templating engine. I am not a web developer, so I am not fully qualified to speak, but in cases where I've needed templating, I've found Apache Velocity and Freemarket to be good options for Java (but most of the time, I am templating, e.g., code to be auto generated or configuration files, rather than web pages).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: