• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Refering images in JSP (path problem).

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,
Need some help from u guys....I am developing an application using JSP and Tomcat 5.0.In the html tag inside jsp pages i am refering to images which r located in a particular folder inside the web application folder.My doubt is when i refer to the image do i hard-code the destination directory or should i use the some other logical method (such that i don't need to hard-code the path) in the jsp page. Kindly advise.....
......thxs in advance.
Prat.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can specify the images in two ways:
1. Document Relative
2. Document Root Relative.
In the former, the reference could be given as:
<img src="../images/cm_banner.png">
where images is a folder directly under the web contents.
In the second way, the path is given as:
<img src="/CIF/CM/images/cm_banner.png">
that is relative to the root. Note that CIF/CM is the context root in this case.
Regards,
Ankur

The image paths can also be hardcoded if you want to, though the practice is not adviseable.
 
prat narang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx ankur,
but what if i have to change the context name itself, then i've to change all the files where i've written the path value.
i need some solution in that scenerio.
thanx
--prat--
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hiii...
for refrencing the contextPath u can write in the following manner..

this should solve ur problem....
if still in doubt do revert back..
Amit Kumar
 
Ankur Jaiswal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
What is the IDE are you using, if you are using one???
As for the solution , you might have to change all the links manually either as document or root relative.
AJ
 
reply
    Bookmark Topic Watch Topic
  • New Topic