How to include an image in a jsp page?

13,022

Solution 1

It may be possible that the image not display because of some path problem so that provide full context path and try it will work for you

<img src="${pageContext.servletContext.contextPath}/img/logo/logo.png" alt="">

Try this one it maybe help you

Solution 2

This will work for you

<img src="../img/logo/logo.png" alt="">
Share:
13,022
Renaud is Not Bill Gates
Author by

Renaud is Not Bill Gates

Updated on June 04, 2022

Comments

  • Renaud is Not Bill Gates
    Renaud is Not Bill Gates almost 2 years

    I'm developing a web application using Hibernate, Spring and JSP.

    In my jsp page I included images as the following :

    <img src="img/logo/logo.png" alt="">
    

    but they are not displayed when I run my jsp page.

    The jsp page is located in :

    WEB-INF/index.php
    

    this jsp page calls three other pages in the same folder as the following :

    <%@ include file="header.jsp" %>
        <%@ include file="sidebar.jsp" %>
        <%@ include file="main.jsp" %>
    

    and images are located in :

    WEB-INF/img
    

    How can I solve this problem ?