• 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

Problem displaying images from "/"

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I trie to display my image with the <html:img struts tag
In the application ressource properties i set the images like this :
/img/image1.jpg
/img/image2.jpg
...
And i would like to use it in any JSP :
/jsp/page1.jsp or /jsp/popup/popup1.jsp

but the image aren't displayed (path incorrect).
So i tried to display the images as this with the <a href html tag :
/myProject/img/image1.jpg
/myProject/img/image2.jpg
...
"myProject" = my project context (in the webapps tomcat directory)
And it works but, you should know it isn't good.
In another application, i haven't this problem but i don't know where is the difference between the two projects about this "/"path problem.
Florent
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use request.getContextPath()/img/xxx.img instead of hardcoding the context root.
This problem happens because the img directory cannot be relatively pointed from the location of the servlet class.
Hope this help.
Nick
[ March 30, 2004: Message edited by: Nicholas Cheung ]
 
Florent LOTHON
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wasn't using the correct attribute of <html:img tag :
i was using srcKey instead pageKey.
So it works fine now
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic