tags:

views:

169

answers:

2

Say I have a JSP page with JSTL. I'm using c:forEach and looping over 5 different sets of objects, each very similar. Each loop is nearly identical.. lots of duplicated code.

I'd like to make that loop a template -- such as a JSP template, but I want to pass the JSTL object(s) in the parameters.

How can I do this?

Or a more general question -- how can I create reusable HTML templates in JSP/JSTL?

A: 

well, it is not perfect but i have some reuse through parametized includes. If you pass the name of the bean in you can in jsp fragments access to beans vith ${xxxxScope[param.beanName]} or ${xxxxScope[param.formName][param.beanName]}

jneira
+2  A: 

You can use tagfiles. These are JSP fragments with well-defined arguments. Should be perfect for what you need.

skaffman
Thanks! This is exactly what I was looking for!
desau