1

I have been building my website with no problem until I added subfolders to my jsp folder and referenced a JSP in a folder above it.

In adventure_by_dkashtan.jsp:

<jsp:include page="${pageContext.request.contextPath}/WEB-INF/jsp/pageHeader.jsp" flush="true"></jsp:include>
<a href="/djkashtanArtPortfolio/artWorkPage.html" target="_self">
    <img src="${pageContext.request.contextPath}/images/artPieces/digitalDrawings/adventure_by_dkashtan.jpg"/>
</a>
<jsp:include page="${pageContext.request.contextPath}/WEB-INF/jsp/pageFooter.jsp" flush="true"></jsp:include>

The error is caused by my reference to pageHeader.jsp in the first line. It works fine when I include pageHeader from JSP files in the same folder as pageHeader.jsp. The file adventure_by_dkashtan.jsp lives in the bottom most folder and the rest live in the jsp folder.

Right now my folder structure looks like this:

webapp
-WEB-INF
--jsp
---artPieces
----digitalDrawings

My page header code:

<html>
<head>
<title>Daniel Kashtan's Art Portfolio</title>
<link rel="stylesheet" href="<c:url value='/css/departments.css'/>" type="text/css" >
</head>
<body>
<h1>Daniel Kashtan's Art Portfolio</h1>

My page footer code:

</body>
</html>
pnuts
  • 58,317
  • 11
  • 87
  • 139
smuggledPancakes
  • 9,881
  • 20
  • 74
  • 113
  • I deleted the get context path part of my path, so now it just starts at /WEB-INF/ and it works! Is this bad to hardcode this path or is this just the best I can do? – smuggledPancakes Feb 10 '13 at 16:29
  • Now you are doing it right. It is totally OK to write full path when including resources. Including content happens at the server side, so the client will get the result and **will NOT see, how some resource was included**. If you are interested in different ways of including content in JSP, check out this answer: http://stackoverflow.com/a/14763794/814702 – informatik01 Feb 10 '13 at 21:30

1 Answers1

2

Try to include the files like this

<%@ include file="/WEB-INF/jsp/pageFooter.jsp" %>

or you can use relative path e.g. ../

iTech
  • 18,192
  • 4
  • 57
  • 80