I’m new to jsp and java and I’m currently trying to display an image on a jsp page from a folder that is located in my C: drive..but for some reason I’m not getting it to show up no matter what I try…I currently have it as shown below:
<img src="/argsdbPics/mazda.jpg" width = "90" height = "55" alt ="mazda"/>
What is the cause of this and how can it be dealt with?
It has to be available by a
http://URL (like as you’d usually enter in browser’s address bar). It’s namely the webbrowser who has got to download the images individually by their URLs, not the webserver who has got to auto-include them during generating the JSP somehow.Easiest way would be to edit Tomcat’s
/conf/server.xmland add a new<Context>element to register a virtual URL on an arbitrary folder. Assuming that the image folder is located inC:\path\to\argsdbPics, here’s an example:This way the folder contents is available by
http://localhost:8080/argsdbPics/.... So if you have amazda.jpgin the folderC:\path\to\argsdbPics, this way it’ll be available byhttp://localhost:8080/argsdbPics/mazda.jpg. This way your following HTML attempt should work: