• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

include file path

 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone explain why I'm getting this error from Tomcat when trying to run a JSP:
org.apache.jasper.JasperException: /countingBeans.jsp(26,0) File "../WEB-INF/jspf/jsptest01/date.jsp" not found
Under a Windows folder SCWCD I have this structure:
/jsptest01/countingBeans.jsp
/WEB-INF/jspf/jsptest01/date.jsp
The offending line of code in countingBeans.jsp is this:
<%@ include file="../WEB-INF/jspf/jsptest01/date.jsp" %>
I will swear that date.jsp does exist in the correct folder.
So, why is it not being found?
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3776
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the dir structure of your <webapp>?
As a rule, you should not keep your jsp files (in fact, any files that you want the user to access) anywhere under <webapps>/WEB-INF directory.
So, the first thing is, you need to fix the directory structure of your webapp. After that, in your jsp file, you can include another jsp file using:
<%@ include file="date.jsp" %>
This is assumming that the including jsp file and the included jsp file (date.jsp) are in the same directory. Usually, jsp files are kept under <webapp>/jsp directory.
If this all sounds confusing to you then you need to read about the directory structure of a webapp from any book (or even the specs explain it very good). This is very important for the exam.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorted it! I had this in my server.xml:
<Context path="/scwcdjsptest01" docBase="C:\projects\SCWCD\jsptest01" debug="1" reloadable="true" />
Now it works with this, ie with jsptest01 removed.
<Context path="/scwcdjsptest01" docBase="C:\projects\SCWCD" debug="1" reloadable="true" />
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a rule, you should not keep your jsp files (in fact, any files that you want the user to access) anywhere under <webapps>/WEB-INF directory.

I've been reading this article http://developer.java.sun.com/developer/technicalArticles/javaserverpages/code_convention/ which says that JSP fragments (with .jspf suffix) should be placed in <context root>/WEB-INF/jspf/<subsystem path>/ .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic