Why is my included JSP not found?

main.jsp is located in this web application directory:

 /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 in another directory:

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

However, this causes the following error:

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

Why is it not found? I checked the location and he appears where he speaks.

+4
source share
3 answers

Change your jsp include tag like this

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

That should work. Check eclipses if they take foo else in the directory by adding another ../ .

+4
source

Everything looks great. If you get this error, it just means that you have a typo in the path (case sensitive!) Or that the file has not actually been published / deployed to the server or that the server really needs to be restarted.

If you are developing, for example, Eclipse / Tomcat, and you just added this file while Tomcat is running, you need to make sure that Tomcat is configured to post changes at run time. To achieve this, double-click the Tomcat entry in the Servers view, go to the Publish section in the upper right and make sure it is installed as follows:

enter image description here


It is the default value that is set to Never publish automatically.

+2
source
 This should work <jsp:include page="/WEB-INF/jsps/foo/includes/mainInclude.jsp"/> 
  • If the problem still exists, clean the project properly.

  • Check if automatic publishing is enabled in the eclipse server settings.

  • The WAR file for the project can be used for deployment on the server to check if there are any problems in Eclipse.

    Get the path to the WEB-INF folder

-1
source

Source: https://habr.com/ru/post/1369302/


All Articles