any info on this would be cool:
i'm trying to create a JSP page and display an image that is stored on the file server and contained within the war file...there are numerous "image" directories within the application
but when i do <img src="<% request.getContextPath(); %>/images/example.jpg"> from within the jsp page the image isn't displayed
the parameter request.getContextPath displays nothing when i check it...so how i can set the contextPath also?
Becasue hard-coding the context path is an egregious violation of best practices.
Originally posted by mark walter:
Niall, If these images are contained within the war file then they are static images. So why do you need to build a dynamic url?
<img src="<path>/images/some.jpg"/> should work just fine.
Look at your code very carefully:
<img src="<% request.getContextPath(); %>/images/example.jpg">
Do you see the error?
Compare it to the code in the JSP FAQ on this issue.
[ August 05, 2008: Message edited by: Bear Bibeault ]