I have a page showing an image and a button. Button uploads the image(acting as submit button for form).The image input is in a form that points to file upload servlet. Servlet succeeds to upload the image. But, It does not display the uploaded image in the img tag.
HTML:
<form id="upload-form" action="UpdatePic" target="upload_f" method="POST" enctype="multipart/form-data">
<img id="pic" name="pic" src="back.png"/>
<input name="pic-selector" type="file" />
<button type="submit"> Upload </button>
<p id="response"></p>
</form>
SERVLET doPost SAMPLE: after upload is done
request.setAttribute("message", message);
getServletContext().getRequestDispatcher("/Message.jsp").forward(request, response);
I want to display uploaded image in img tag. What do i do?
Edit:
I know how to display images dynamically or from blobs. I want to show uploaded image as soon as upload is complete. Only by the action of click on Upload button. I need to add something to response so that it tells webpage that image is uploaded. and response will set img tag's src attribute somehow or use jQuery (.load function). But, as a part of response by servlet.