I am currently writing a template for OpenCms, a Java based CMS with a very good taglib-support and a powerfull API.
Anyway, when I look at tutorials or the source, its about 50-50 that taglibs or Javaclasses are used to generate (html)-output.
I try to keep my JSPs clean, meaning not to much scriplet code (instead using JSTL and so on). At some point I could need more control over the code, thats were the Java-classes come in and here I dont know how far I should go (I personaly dont like the idea of generating HTML in a class).
Here are some pros & cons I have though of:
- With taglibs, I dont have to restart the servlet container each time. I just make my changes and see the outcome
- A taglib JSP is easier to maintain, especially for webdesigner because of the "same" syntax
- A Javaclass provides full/more IDE support (type/syntax check)
- With more complex requirements the Javaclass-code is cleaner (compared to putting variables to the pagecontext in JSPs)
- EL (expression language) add more power to the JSP/taglib but thats another syntax again and needs to be learned
Are there any best-practises on how to approach this? Since there are other collegues, that probably have to maintain this in the future, I am looking for a clean/maintainable solution - You probaly all know the situation when you looked at somebodies code and though "what the hell was he/seh thinking" ;)