image « Response « JSP-Servlet Q&A

1. How to show a JSP page using Servlet which has image in its Response?

Servlet doGet() code for getting an Image from Database and to store image in Response

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws 
ServletException, IOException {

// Get userid from session

try {


2. How to send image in servlet response to ajax?

I am uploading an image file from database to jsp. I've selected image using SQL as below

select (logo_img_one) from accounts_logo where logo_usrm_id=1
I read the image using binarystream as
InputStream readImg = ...