It looks like you're trying to return several images in a single HTTP response; that doesn't work: 1 response = 1 image.
Delete the call to response.getWriter(); you can only call getWriter()
or getOutputStream, not both.
You should also make sure that
index == len; although that's likely to be the case, it's by no means guaranteed. You may have to call readImg.read in a loop to get all the bytes.