File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Path related problem

 
surya sudhakar
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic