I have several JSP's that need to refer to gifs in the /images directory of a war file. The JSP is contained within the same war file.
Using SRC="/images/.." in the JSP refers to the root on the web server and not the root in the war file. Why?

Ryan Breidenbach

"/images/.." resolves to "http://<host>/images/.." because this done by the browser, not the server. If all your JSP pages refer to images with static text, like <IMG SRC="/images/graphic.gif">, then the page will be sent with this exact same text to the browser. The browser then simply interprets this as the "images" directory below your web root directory.

An alternative to this would be to dynamically populate the images directory in your JSP. Maybe do something like <IMG SRC="<%= imageDir %>/graphic.gif">, where imageDir is a JSP variable that represents the actual directory where the images are stored. Rememer, this path still will ultimately be resovled relative to your web root, but this gives you some configurablilty.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.