Why is my included JSP not found?

Bert picture Bert · Aug 27, 2011 · Viewed 28k times · Source

The main.jsp is location in this directory of the web app:

/WEB-INF/jsps/foo/section/main.jsp

main.jsp contains the following line of code to try to include the code contained in mainInclude.jsp which is found in a different directory:

<jsp:include page="/WEB-INF/jsps/foo/includes/mainInclude.jsp" />

However, this generates the following error:

javax.servlet.ServletException: 
File '/WEB-INF/jsps/foo/includes/mainInclude.jsp' not found 

Why is this not found? I checked the location and it appears where it says it is.

Answer

Ravindra Gullapalli picture Ravindra Gullapalli · Feb 1, 2012

Change your jsp include tag like this

<jsp:include page="../includes/mainInclude.jsp" />

That should work. Check the eclipses if they are taking to the foo directory else put one more ../ there.