// Suppose we have a byte array containing the image: byte[] img; // we should return it in the response: response.setContentType("image/jpg"); OutputStream os = response.getOutputStream(); BufferedOutputStream bos = new BufferedOutputStream(os); bos.write(img, 0, img.length); bos.close();