Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring MVC: Including a JSP inside a view (JSP is installed next to view so is inaccesible from outside controller)?

I have created a view and its working well but i now need to Include another JSP inside the page.

Considering my views are installed in the protected area of WEB-INF/Views (hence its not available in my resources directory where my imgs, css are)

I have tried using

   <%@ include file="/views/shared/items/NewItem.jsp" %>

And it always gives me FileNotFound, taking into consideration that my NewItem.jsp is installed with my other views (i.e. NOT accesible via the normal routes but controlled by controllers) how can i include a JSP files that is installed next to my view

If i take out the "include file" my view renders without issues.

I am sure i am missing something here?

Thanks in advance

like image 268
Martin Avatar asked Dec 01 '22 23:12

Martin


1 Answers

If NewItem.jsp is in /WEB-INF/views/shared/items/NewItem.jsp, then you have to use this path when incuding it:

<%@ include file="/WEB-INF/views/shared/items/NewItem.jsp" %>
like image 92
JB Nizet Avatar answered Dec 16 '22 17:12

JB Nizet