I’d like to pack up presentation aspects of an application in a modular way; if I have a set of functionality in a separate JAR project, I’d like to keep UI elements related to that aspect separate from the core webapp code.
I think that tag libraries were the way to do this, so a lib could contain a bunch of classes implementing special interfaces and a descriptor. Then, the only footprint that the modular piece has would be one/more tags. Ideally, I’d like to avoid a runtime dependency on some specific modular piece being there… not sure how to achieve that!
Are tag libraries still the way to go? Or are there better options?
No, I wouldn’t say so. The temptation to embed logic into those tags is too great. It locks too much stuff in the UI where it doesn’t belong. How will that play when you need a mobile or tablet UI?
The only tag libraries you should need are JSTL.
JSF is a failure. I’d steer clear of that.
I would say that you’re better off keeping your view layer as slim and simple as possible. Base it on HTML, CSS, and JavaScript. Put all the logic in services that are reusable and more likely to stick around as UIs come and go.
I use Velocity templates to generate HTML and map dynamic data from Spring models. I wouldn’t use JSP or JSF unless forced to.