File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » JSP
Bookmark "Path related problem" Watch "Path related problem" New topic
Author

Path related problem

surya sudhakar
Greenhorn

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
sudhakar
Anonymous
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 (http://www.yourwebserver.com/), 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.:
http://www.yourwebserver.com/myapplication/
then you will have to use the following absolute path:
/myapplication/images/somepicture.gif
Good luck!
Beno�t
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Path related problem
 
Similar Threads
Where to place the images for userguide.html
gif/jpeg images not displayed if the package location is changed
accessing our own web application without changing the default root
Changing <context-root>
Display All images from a folder on a html/jsp page