Hi guys I am trying to get images from database and display it in JSP but when i passed my imageId inside it will call servlet but override image here is my code
<c:forEach var="row" items="${result.rows }">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs 12 well-profile">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs 12 ">
<span class="text-name"><c:out value="${row.Name }"></c:out></span>
<span class="text-xs col-md-offset-6 col-xs-offset-6"> Profile Created By: <c:out value="${row.ProfileBy }"></c:out></span>
</div>
<div class="col-lg-3 col-md-3 col-sm-12 col-xs 12">
<img class="img-responsive well-image" src="${pageContext.servletContext.contextPath }/PhotoServlet?id=${row.id}" />
</div>
</div>
</c:forEach>
My Servlet Code
id=request.getParameter("id");
System.out.println("Photo Id:"+id);
try{
con=DBUtility.getConnection();
stmt=con.prepareStatement("select Photo From personalinfo where id=?");
stmt.setString(1, id);
rs=stmt.executeQuery();
if(rs.next()){
response.getOutputStream().write(rs.getBytes("Photo"));
}
}catch(SQLException ex){
ex.printStackTrace();
}finally{
DBUtility.closeConnection();
}
JSP page sometime Shows different image based on id and sometimes it will show same image for all.