4

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.

Jasper
  • 2,166
  • 4
  • 30
  • 50
Bert
  • 41
  • 1
  • 1
  • 2

3 Answers3

5

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.

Ravindra Gullapalli
  • 9,049
  • 3
  • 48
  • 70
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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I think this is the default. Also, I think when "publishing" it restarts the server, while if you 'never publish', resources still get copied, and it's up to tomcat to pick them up. But I'm not sure. – Bozho Aug 27 '11 at 22:09
  • Depends likely on server plugin used. But indeed, Tomcat is a very poor publisher. Glassfish is way much better. – BalusC Aug 27 '11 at 22:12
-1
This should work <jsp:include page="/WEB-INF/jsps/foo/includes/mainInclude.jsp"/>
  • If the problem still exists clean the project properly.

  • Check whether if the Auto publish is enabled in server settings of eclipse.

  • A WAR file of project can be used to deploy in server to check there is any problem in Eclipse.

    Get the WEB-INF folder path

Srikanth Venkatesh
  • 2,812
  • 1
  • 20
  • 13