简体   繁体   中英

How to display an image in jsp page?

I know that this question is being asked a lot but I still have a problem. I work on a web application using Apache-Tomcat and MySQL database to store the path of each image I want to display but it's not working so please if anyone write me down step by step how to display any image on a jsp page and where exactly I store my images for display on my webapp

<div ><img src="<%=request.getContextPath() %>/images/logo.gif"  title="Your Title" /></div>

I don't see why this wouldn't work with regular html, so it would depend on what path you are retrieving from MySQL, meaning if it is the full URL to the file or a relative URL to the file.

In the case of a full URL you just have to do the following: <img src="your_full_url_here"> In the case of a relative URL just prepend or append the missing information to reach the file, such as: <img src="your_relative_path' + restOfPathVariable>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM