The moose likes HTML, CSS and JavaScript and the fly likes Conversion of the paths of the names of the  image files ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Conversion of the paths of the names of the  image files ??" Watch "Conversion of the paths of the names of the  image files ??" New topic
Author

Conversion of the paths of the names of the image files ??

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
what system should I use in order to use images in my web pages? the relative paths ( . and .. format i mean) have not been working.
Where am I doing wrong?
when I use http://ip_adress ort#/web_appln/images/xxx.jpg it shows up, but that should not be the optimal way!!
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50674

Relative paths in a page are relative to the URL that you used to get to the page, and not to the actual location of the page file.
When using "straight" URLs, these are the same so there's no problem. If you are using any kind of servlet mapping (or any other type of mapping where the URL no longer reflects the folder structure on the disk) you'll have problems.
Two solutions come to mind:
1) Use context-relative URLs. For example, if your web app is named xyz:

2) Use relative URLs as before, but use the <base> tag to set the URL to the one which you expect all relative references to be based on.
hth,
bear


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
merci Bear,
appreciated really. I have forgotten this important detail.
 
IntelliJ Java IDE
 
subject: Conversion of the paths of the names of the image files ??
 
Threads others viewed
Hyper link Doubt
using RequestDispatcher.forward()
storing image
Referring Script outside WEB-INF
ServletFilter to allow/deny directory access -> save against "hackers"?
MyEclipse, The Clear Choice