Renaud is Not Bill Gates
Renaud is Not Bill Gates

Reputation: 2084

How to include an image in a jsp page?

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 ?

Upvotes: 2

Views: 14626

Answers (2)

This will work for you

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

Upvotes: 1

Nirav Prajapati
Nirav Prajapati

Reputation: 3005

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

Upvotes: 2

Related Questions