Well. Good question.
This is a solution: writing a custom jstl tag to Evaluate a property expression of a bean:
<mytag:eval bean="${requestScope['formKey']}" propertyExpression = "${path}" var="items" />
And ForEach:
<c:forEach var="toc" items="${items}">
</c:forEach>
Sample code of mytag:eval JSTL tag ( Classic model )
public class EvalTag extends TagSupport
{
private Object bean;
private String propertyExpression; //Ex: 'model.sharingTocs'
private String var;
//............
@Override
public int doEndTag() throws JspException {
try {
// Use reflection to eval propertyExpression ('model.sharingTocs') on the given bean
Object propObject = SomeLibs.eval ( this.bean, this.propertyExpression);
this.pageContext.getRequest().setAttribute(this.var, propObject);
// You can add propObject into Other scopes too.
} catch (Exception ex) {
throw new JspTagException(ex.getMessage(), ex);
}
return EVAL_PAGE;
}
//............
// SETTERS here
}
A lib you can use to eval propertyExpression of a bean is Apache bean utils.
http://commons.apache.org/proper/commons-beanutils/apidocs/org/apache/commons/beanutils/package-summary.html#standard.nested