Reputation: 49
I have some question about include tags.
Is it correct to use a structure like this:
<c:choose>
<c:when test="${info == 'view_users'}">
<jsp:include page="/WEB-INF/jsp/admin/view_users.jsp" />
</c:when>
<c:when test="${info == 'view_products'}">
<jsp:include page="/WEB-INF/jsp/admin/view_products.jsp" />
</c:when>
<c:when test="${info == 'edit_product'}">
<jsp:include page="/WEB-INF/jsp/admin/edit_product.jsp" />
</c:when>
<c:when test="${info == 'view_categories'}">
<jsp:include page="/WEB-INF/jsp/admin/view_categories.jsp" />
</c:when>
</c:choose>
Sometimes, I get an exception:
JasperException: Unable to compile class for JSP
.
Is my problem will be solved if I use static include instead of dynamic, by using an include
directive in JSP, or do I need to give up such a structure? All included pages have a fixed structure, not dynamic.
Upvotes: 0
Views: 732
Reputation: 1
The structure could be simplified but it won't resolve your compilation problems.
<c:import url="/WEB-INF/jsp/admin/${info}.jsp" />
Instead delegate this logic to controller (using MVC) to decide which view should be returned and properly initialize the view.
Upvotes: 1