Why is my included JSP not found?

28,713

Solution 1

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.

Solution 2

Everything looks fine. If you get that error then it simply means that you've a typo in the path (case sensitive!), or that the file actually isn't been published/deployed into the server, or that the server actually needs to be restarted.

If you're developing with for example Eclipse/Tomcat and you just added that file while Tomcat is running, then you need to ensure that Tomcat is configured to publish changes while running. To achieve that, doubleclick Tomcat's entry in Servers view, head to the Publishing section on the right top and make sure that it's set as follows:

enter image description here


It's namely by default set to Never publish automatically.

Share:
28,713
Admin
Author by

Admin

Updated on July 28, 2022

Comments

  • Admin
    Admin almost 2 years

    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.