Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP file Include path fails with tomcat 6.0

 
Nina Anderson
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I just switch from a Websphere server to a Tomcat server. Now all my file include paths are broken. Tomcat can not find the specified paths. What's the problem?

Here's my JSP code:

<%@ include file="../common/Header.jsp" %>

This is the error Tomcat is throwing:

org.apache.jasper.JasperException: /web/search/home.jsp(5,0) File "/web/search/../common/Header.jsp" not found


Tomcat should have found the file in:

"/web/common/Header.jsp"
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the exact location of the include file and the file that uses it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64701
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is ill-advised to use page-relative paths. I'd change them to context-relative paths.
 
Nina Anderson
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to include a file in my JSP as well as images on the page and Tomcat is still not recognizing the file paths.

The following is my project hierarchy:



In my home.jsp, I changed the included statement from

<%@ include file="../common/Header.jsp" %>

to

<jsp:include page="/common/Header.jsp" %>


I've never used Tomcat before, so can some pls tell me What I'm I doing wrong??
[ December 10, 2007: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64701
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nina Anderson:
I'm trying to include a file in my JSP as well as images on the page and Tomcat is still not recognizing the file paths.
You need to specify them correctly.

The following is my project hierarchy:
This was not very helpful because you did not enclose the list in CODE tags to preserve the indentation. I added them on your behalf. Please be sure to use CODE tags in the future.

-> WEBINF


WEBINF or WEB-INF? If the latter, please take more care when posting. Please read this for more information.

<jsp:include page="/common/Header.jsp" %>


common or Common? Case counts! Pick one and use it consistently. Most experienced developers will always use all lowercase.

Your common folder is under WEB-INF. Don't you think you;d need to include that as part of your path?
[ December 10, 2007: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic