here is the JSP call:
<img src="/ImageServlet?imagestorecode=FBBRA" width="300"
height="140">
//the servlet class
/********************************
public class ImageServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse res
) throws ServletException, IOException {
ServletOutputStream out = res.getOutputStream();
try {
//set the content type to image
res.setContentType("image/gif");
//get the storecode parameter from the HTTP request.
String storecode = req.getParameter("imagestorecode");
Tools.debug("The request param is: " + storecode);
//Store the image in the byte array
byte[] buff = ImageServletHelper.getImage(storecode);
Tools.debug("The buffer copy size is " + buff.length);
//handle to the outputstream
BufferedOutputStream bos = new BufferedOutputStream(out);
bos.write(buff);
Tools.debug("Completed the imagewrite to Buffer ");
bos.flush();
bos.close();
Tools.debug("Buffer flushed ");
} catch(IOException ioe){
Tools.log(ioe);
} catch (Exception excp){
Tools.log(excp);
}
}// end doGet
//
//old code removed from here.
//
protected void doPost(HttpServletRequest req, HttpServletResponse res
) throws ServletException, IOException {
doGet(req,res);
}
}
/********************************************************
//The Exception for some of the images.
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite(Native Method)
at java.net.SocketOutputStream.write(SocketOutputStream.java:83)
at weblogic.servlet.internal.ChunkUtils.writeChunkTransfer(ChunkUtils.java:189)
at weblogic.servlet.internal.ChunkUtils.writeChunks(ChunkUtils.java:165)
at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:248)
at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:306)
at weblogic.servlet.internal.ChunkOutput.write(ChunkOutput.java:197)
at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:121)
at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:155)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:112)
at nlg.ImageServlet.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet