First you have to understand that images displayed "within" an HTML or JSP page are actually downloaded as seperate requests. You need to coordinate this request to whatever is going to supply the image (i.e. a
servlet). So the HTML or JSP has some image tag in it:
In that tag, "getImage.do" is what we have our image servlet mapped to in our app server and "?id=5" is a request parameter specifying that the image id is 5 (unfamiliar with servlets? get
reading).
The servlet gets the request parameter "id" out of the request object it is passed in its doGet() or doPost() methods. Use that index to look up the appropriate image in the database. ResultSet has a getBinaryStream() method so we read out of that stream and write to the servlet response object's OutputStream. Use the servlet response object's setContentType() method to the
MIME Type of the image (i.e. "image/gif") for GIF images). The browser downloads the image and displays it. Simple, eh?