JSP Templates
October 10, 2005 2:24 AM   RSS feed for this thread Subscribe

JSP templates as templates - am I reinventing the wheel?

I'm using Spring's MVC with JSP views. Every JSP page has similar structure - headers, content, footers, perhaps a sidebar, etc. Looking around for "best practices" people seem to "include" footers and headers, but that means that every JSP page includes these "include" statements, giving a fixed format. To my eye a better solution would involve nested views, where a base template is extended with information appropriate to the page in question. One advantage of this approach is that you can have default values assumed in the base template without repeating them elsewhere. Another advantage is that you can further separate structure and content ("header" and "footer" being structural, and so belonging in the base template) in pages which contain a lot of text (think of help pages - you could put all that in the database, but why bother, especially since with Spring you can resolve to different views via the locale?).

There doesn't seem to be any support for this at the MVC level in Spring, but it could be implemented in JSP using custom tags and, indeed, there's a rather clunky attempt here (that might explain what I want better than this question, although I think you could make it less intrusive).

Anyway, my question is - does this already exist as a (popular/standard) tag library? I'm happy writing custom tags, but my impression of this stuff (generating web sites) is that there's a huge range of solutions already out there, with most work going into choosing the correct tools (eg Spring). Thanks.
posted by andrew cooke to computers & internet (2 comments total)
Yes, you're reinventing the wheel called sitemesh. Stop it.
posted by nixerman at 5:29 AM on October 10, 2005


Also take a look at Tiles. It's packaged with Struts but can be used independently of it.
posted by nev at 7:53 AM on October 10, 2005


« Older When viewing enhanced podcasts...   |   Love-triangle Filter. I am cl... Newer »

You are not logged in, either login or create an account to post comments



Related Questions
Where does a small web design/development company... March 29, 2008
Is Web Development about to change? March 13, 2008
Where to begin with Ruby on Rails? December 29, 2007
Creating Jen 2.0 June 2, 2007
Transforming XML with XSL March 7, 2005