wood burning stoves*
The moose likes Tomcat and the fly likes File path in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "File path in Tomcat" Watch "File path in Tomcat" New topic
Author

File path in Tomcat

Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
My image files are not displayed on my jsp pages. The container cannot read the relative path.

My app. name is : dice
My imge files are in: dice/images
my context path in server.xml is : /dice

In my jsp I have <img src="/images/home/question_mark.gif">
This .gif file cannot be displayed.
If I modify it to be <img src="/dice/images/home/question_mark.gif">
It works fine

What puzzling me this code works fine: <%@ include file="/doc/help.html" %>

Both the directive and the html code use relative paths. One works, and the other doesn't. How can I tell the container to look at the relative path of the application.

Thanks

Thanks


SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
If I understand your problem correctly then both of these should work
<img src="/dice/images/home/question_mark.gif">
<img src="images/home/question_mark.gif">

the first one since it now points to the root (provided that the server is configured so that the image is located here http://domainname/dice/images/home/question_mark.gif)
and the second one since now you don't start at the root but from where you are currently located. This of course requires that the page that has the link is viewed to user at the root of "dice/".

Hope this helps.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

See:
http://faq.javaranch.com/java/ResourceUrlProblems
and
http://faq.javaranch.com/java/RelativeLinks

To learn the ins and outs of relative links in a server side Java app.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
Solved..

Moilanen,
Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File path in Tomcat
 
Similar Threads
img tag in jsp
Struts-1 Creating a File inside the
unable to display image files in jsp
Export image in a word document using a jsp
Export image in a word document using a jsp