wood burning stoves 2.0*
The moose likes JSP and the fly likes JSP file Include path fails with tomcat 6.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP file Include path fails with tomcat 6.0" Watch "JSP file Include path fails with tomcat 6.0" New topic
Author

JSP file Include path fails with tomcat 6.0

Nina Anderson
Ranch Hand

Joined: Jul 18, 2006
Posts: 148
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

Joined: Dec 11, 2004
Posts: 13410

Post the exact location of the include file and the file that uses it.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

It is ill-advised to use page-relative paths. I'd change them to context-relative paths.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nina Anderson
Ranch Hand

Joined: Jul 18, 2006
Posts: 148
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

Joined: Jan 10, 2002
Posts: 61657
    
  67

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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP file Include path fails with tomcat 6.0