5
votes

How can include JSPs file from another folder: My hierarchy is WebContent/WEB-INF/JSPs/..

My JSP file to be include is from /WebContent/WEB-INF/JSPs/body/content.jsp and the JSP file where will i include the file is /WebContent/WEB-INF/JSPs/header/navigation.jsp

What i tried so far is:

  1. <jsp:include page="../JSPs/header/navigation.jsp"></jsp:include>
  2. <jsp:include page="/WebContent/WEB-INF/JSPs/header/navigation.jsp"></jsp:include>
2
Was the double ".jsp" extension intended or just a typo in page="../JSPs/header/navigation.jsp.jsp"? - Morfic

2 Answers

9
votes

You should use jsp include tag as shown below from any jsp file.

<jsp:include page="/WEB-INF/JSPs/header/navigation.jsp"></jsp:include>
<jsp:include page="/WEB-INF/JSPs/header/navigation.jsp"></jsp:include>
5
votes

Your relative path is wrong. Use:

<jsp:include page="../header/navigation.jsp"></jsp:include>