开发者

Why is my included JSP not found?

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

/WEB-INF/jsps/foo/section/开发者_C百科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.


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.


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:

Why is my included JSP not found?


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜