Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java.net.SocketException: Connection reset by peer: socket write error

6 views
Skip to first unread message

Navin

unread,
Jun 5, 2002, 5:24:03 PM6/5/02
to
Hi,
I am getting this error when I am retrieving an image using a
servlet. The servlet retrieves an image from the database ( using a
Helper class )and serves it to the JSP page that calls this servlet.
This error occurs only with some images and not all. Has anyone faced
this problem before. Any suggestions or pointers in the right
direction will be welcome.
Here is the code ( not all of it but the main method)

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

0 new messages