Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying images  RSS feed

 
Paul Giancola
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is strange to me. I have a new JSP project with images that reside in an 'images' folder within the WEB-INF folder. Although the path to the images is correct (i.e., src="/images/companyLogo.jpg") none of the images display. Does anyone have any ideas about this?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your images should not sit under the WEB-INF folder unless they are used on the server side using the getResource or getResourceAsStream APIs.
Put the images folder in the root of your application directory and then they should display.
Cheers
 
Michael Bronshteyn
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would check following things.
1. Images should not be behind WEB-INF, because servlet container protects WEB-INF. Put images in the same directory as your html/jsp in images subdirectory.
2. When servlet container runs, its path is where you started it ( <tomcat>/bin directory for tomcats ). You will need to use real path ServletContext.getRealPath() method to get real path to web application and add your location behind WEB-INF.
3. If you have a lot of images which are accessed from html, I would setup web server, such as apache to get them. This will improve performance of you web application. Don't map apache to look behind WEB-INF, because you will create a security breech in your web application.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!