'Uploaded images are not displayed in forwarded jsp until I refresh the page in javaEE?

I am working on a project where during filling form user has to upload an image, after saving form details in the database I am forwarding to jsp to display the image, but it does not show until I continously refresh the page for 2 or 3 times.

How can I resolve this issue? project hierarchy is displayed in the picture

This is the path where I am saving my uploaded images: bookPicPath /opt/tomcat/apache-tomcat-9.0.58/webapps/library-management/src/main/webapp/assets

This is the code for getting displaying images in jsp:

<div class="book-box">
    <img alt="${book.title }" src="${'assets' += File.separator += book.picPath}"><br>
    <a href="<c:url value="book">
        <c:param name="action" value="view"/>
        <c:param name="ISBN" value="${book.ISBN }"/> </c:url> " class="book-title"><i>${book.title }</i>
        </a>
</div>

The question is that image is uploaded successfully, but display takes time, untill I refresh the page two or three times. Here is the output: Output



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source