java - JSP include directive, jsp:include action, relative vs. absolute paths -


I am doing some basic template in my JSP based webpap. For example, I have to keep a standard header and footer (basic HTML) that I pull into my JSP.

My content is on JSP /WEB-INF/jsp/home.jsp , and I have / WEB-INF / jsp / template / The template is JSPs, such as /WEB-INF/jsp/template/Body-Footer.jsp .

So now, within home.jsp , I want to draw in my template files. First of all, I have jsp: include verb:

  & lt; Jsp: include page = "template / body-footer.jsp" & gt; & Lt; / Jsp: include & gt;  

This error generates the javax.servlet.ServletException: File & amp; Quot; /template/Body-Footer.jsp& Quot; Not found

I am strange, eclipse believes that path is valid.

OK, so I switch to the included command:

  add the & lt;% @ file = "template / body-footer.jsp"% & gt; ;  

It just works fine, drages my footer into HTML.

but why do not work? After some experimentation, I feel that putting it in the full path gives it work:

  & lt; Jsp: include page = "/ WEB-INF / jsp / template / body-footer.jsp" & gt; & Lt; / Jsp: include & gt;  

Now it works fine, no error.

So my question is: Why? Why is there a need to use a full path with jsp: include operation, but why not include it with the instructions included?

/WEB-INF/jsp/template/Body-Footer.jsp There is not a complete path. It is also a relative path problem that template / body-footer.jsp is an incomplete relative path, while the other is complete. That is, the paths are relative to your app path because / WEB-INF / is under your app path, you have to include it. Absolute path means c: / program files / tomcat / webapps / your app / web-nf / jsp / template / body-priest.jsp


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -