views:

116

answers:

2

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?

+1  A: 
<c:import url="../themes/${theme}/jsp/content/welcome.jsp"/>
Maurice Perry
+1  A: 

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.

evnafets