In here, you are trying to output all the binary data of the image to 'src' attribute of the image html tag. See the html source of the generated code and you can verify that.
What
you should have done is set the value of the 'src' attribute to a
servlet which print the binary data stream of the image using a output stream and set the content type of that output response to relevant image mime type.
e.g.:
Where relevant servlet mapped to "/imgegenerateservlet.do" URL will read the image (can use a variable similar to which I have mentioned here 'imgid' to select the relevant image) from the database and set thecontent type of the response to an image related mime type such as 'image/jpeg' and then write the image data to the response using output stream.
I am not much familiar with
EJB related things. So I don't know how to achieve this using EJB related stuffs.
Thanks & Regards,
Manjula