Question

I would like to include a file depending on a request attribute value.

${theme} -> themeA

To sum up. I would like something like this:

<%@ include file="../themes/${theme}/jsp/content/welcome.jsp"%>

Any easy workaround?

Was it helpful?

Solution

Not with <%@ include%> as that is a static/compile time include. You could instead use <jsp:include> tag, which is evaluated at runtime, and includes the result of executing that page, rather than including the page itself at compile time.

To compare all the differences between the include directive and <jsp:include> check out JSP2.0 Reference

<jsp:include page="../themes/${theme}/jsp/content/welcome.jsp"> 

The <c:import> tag would also work if you are using JSTL.

OTHER TIPS

<c:import url="../themes/${theme}/jsp/content/welcome.jsp"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top