I just wrote another article for CQ Blueprints.

Within CQ, Components (including Page Templates) can utilize JSPs for rendering not only HTML, but also other output formats such as JSON.

Unfortunately, many JSPs are written poorly and mix presentation logic with business logic (in the form of scriptlets) making them difficult to test, debug and maintain. One of the best ways to write better JSPs is to never use scriptlets and instead use a combination of EL expressions and Custom Tag Libraries (including the JSTL). This Blueprint details how Custom Tag Libraries should be developed and deployed to a CQ environment.

For more, see:
http://www.cqblueprints.com/xwiki/bin/view/Blue+Prints/Writing+A+JSP+Custom+Tag+Library