I am using following code to display an image in a JSP page:
<img src="images/images.jpg" alt="logo" width="150" height="150"/>
In my Netbeans server application, it works fine. However, can anybody tell me if this works for a real Client-Server application? If a client accesses that JSP page, will they be able to see the image?
The
<img>tag is a standard HTML tag, and as such will be sent from the server to the browser “as-is”, because the server-side code doesn’t need to do anything with it.Once deployed on to an actual web server, anybody accessing the page should be able to see the image, provided that it exists on the server in the correct location relative to the JSP page the tag is on. Or, more specifically, provided there is an “images.jpg” file located within an “images” directory that’s in the same directory as the JSP page.
The JSP page is translated on the server, and generates HTML that’s sent to the browser. The browser then uses that in the same way it would use a standard
.htmlfile – it creates the DOM from the tags, and loads images, scripts, etc from the server specified in thesrcattributes of the corresponding tags.