简体   繁体   中英

Error on including a file in directive in JSP

I am trying to include a JSP page using directive in another JSP.

My code is:

<%@include file="${pageContext.request.contextPage}/Pages/Loader/
load-resources.jsp" %>

As you can see here clearly that my url should be like

localhost://port/WebApp1/Pages/Loader/load-resources.jsp

But on execution i am receiving this error which says this URL does not exist. But i passed url in reference from contextPage.

Caused by: org.apache.jasper.JasperException: PWC6117: File 
"/Pages/Test/Take/${pageContext.request.contextPage}/Pages/Loader/
load-resources.jsp" not found

How to resolve this issue?

Ok, if you want to include Pages/Loader/load-resources.jsp , simply use :

<%@include file="/Pages/Loader/load-resources.jsp" %>

You do not include an URL, but a file . The root of the hierarchy is simply the root of your web application.

By the way, are you aware of the differences between the directive <%@include ... %> and the tag <jsp:include .../> :

  • with the directive, you include the source file, meaning all page context variables will be shared
  • with <jsp:include .../> , you include at output level, meaning each page will have its own page context

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM