I wanted to post this because I searched for an answer to this over 2 years ago and didn't find one. I just search today and didn't either. I found two old postings on the JavaRanch from back in 2007 and neither of them had what I would call an elegant solution. I think I finally have a pseudo-elegant solution and I want to see if anyone can poke holes in it.
Here is the template:
Here is my test html. I did not do portlet code because we are using this "design" already in production so that is tested out.
Once I have it out in a js file I can also minify it which is something I could not do if I went the include jsp route. This solution also addresses an issue a developer is having here in that a compiled JSP exceeded some size limit. I won't go into the whole design of the page since it could be argued it is too big but being able to remove the JS will help solve that for him. If we did an include JSP mechanism it still would have been part of the compiled page.