I want to retrieve images from a database (MySQL, saved as a LongBlob field). They can be .gif, .jpg or .png images. Returning them to the client from the servlet requires using something like, to set the content type:
response.setContentType("image/gif");
But this only works properly in all browsers if the image is a gif. Can I identify if the image is a gif or jpg by reading the bytes or can I specify a generic ContentType that handles all images.