It's not a secret anymore!
The moose likes JSP and the fly likes Path related problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Path related problem" Watch "Path related problem" New topic

Path related problem

surya sudhakar

Joined: Jun 11, 2002
Posts: 18
Hi All,
I have a doubt regarding the paths to be specified in the JSP for the resources like Html pages and pictures.
Lets consider a case where I have to show images in an Html file generated by a JSP. I am maintaining all the images in a directory called "images" in the webapplication directory.
What happens if i specify the src for the images in the following cases.
First case : "images/somepicture.gif"
Second case :"/images/somepicture.gif"
and what is the exact difference between the two and when to use what.
Thanx in advance
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Sudhakar,
In thew first case, you are using a relative path to your images. This means that the images will only display if originated from a page sitting at the root of your application directory (well, WEB-INF).
If you happen to use subdirectories for your webpages, this won't work anymore...
The second form references a absolute path, i.e. if your web application is installed at the root of your webserver (, the images will display regardless of where your html/jsp pages are located.
If your web application is mounted in a subdirectoy of your web server, e.g.:
then you will have to use the following absolute path:
Good luck!
I agree. Here's the link:
subject: Path related problem
It's not a secret anymore!