1 Reply Latest reply on Sep 5, 2002 5:38 PM by 843835

    Problem with multiple images in a JSP (Connection reset by peer)

    843835
      Hi,
      I have a JSP page that calls a servlet to create image thumbnails. I am also using javascript, because once those thumbnails are loaded the user can click on any one of them to see the full picture (once again the full image will be produced by the servlet).
      So, I have a lot of the following lines :
      document.write('<img border="0" src="../servlet/DisplayXwd?pic=img1&size=thumb" onclick="displayPic(img1)">');
      
      document.write('<img border="0" src="../servlet/DisplayXwd?pic=img2&size=thumb" onclick="displayPic(img2)">');
      ... and so on.

      I have about 30 thumbnails to display. Now, when I open up only one browser most of the time these thumbnails appear correctly. But, the problem usually happens when I have more than one browser open requesting the same page, then some of the thumbnails appear as broken links.

      On the servlet side I am using ImageIO to send each BufferedImage across like this:
                  res.setContentType("image/jpeg"); 
                  ServletOutputStream sos = res.getOutputStream();
                  ImageIO.write(bImg,"JPEG",sos); 
                  sos.flush();
                  sos.close();
      My Tomcat 4 server shows that I am getting a "SocketException: Connection Reset by Peer" Exception. I dont really understand why that connection would be interrupted for only a few of the images on the page, while the rest load fine.
      Could somebody please help me find the error or suggest an alternative method.

      Thanks a lot,
      Val.

      p.s. I am thinking about using an applet instead of mine JSP page with HTML frames to display the thumbnails, but then again BufferedImages are not serializable, so I'll have to figure out a way send them to the applet.

      p.p.s. Here is the full Exception thread from the Tomcat log:

      2002-09-05 11:53:50 StandardWrapperValve[DisplayXwd]: Servlet.service() for servlet DisplayXwd threw exception
      java.net.SocketException: Connection reset by peer: socket write error
           at java.net.SocketOutputStream.socketWrite0(Native Method)
           at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
           at java.net.SocketOutputStream.write(SocketOutputStream.java:126)
           at org.apache.catalina.connector.ResponseBase.flushBuffer(ResponseBase.java:679)
           at org.apache.catalina.connector.HttpResponseBase.flushBuffer(HttpResponseBase.java:757)
           at org.apache.catalina.connector.ResponseBase.write(ResponseBase.java:652)
           at org.apache.catalina.connector.ResponseStream.write(ResponseStream.java:312)
           at org.apache.catalina.connector.http.HttpResponseStream.write(HttpResponseStream.java:182)
           at javax.imageio.stream.FileCacheImageOutputStream.flushBefore(FileCacheImageOutputStream.java:209)
           at javax.imageio.stream.ImageInputStreamImpl.flush(ImageInputStreamImpl.java:801)
           at com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:957)
           at javax.imageio.ImageWriter.write(ImageWriter.java:591)
           at javax.imageio.ImageIO.write(ImageIO.java:1365)
           at javax.imageio.ImageIO.write(ImageIO.java:1439)
           at net.progeny.tools.imageViewer.servlet.DisplayXwd.processRequest(DisplayXwd.java:82)
           at net.progeny.tools.imageViewer.servlet.DisplayXwd.service(DisplayXwd.java:108)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
           at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
           at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
           at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
           at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
           at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
           at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
           at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
           at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
           at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
           at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
           at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
           at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
           at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
           at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
           at java.lang.Thread.run(Thread.java:536)
        • 1. Re: Problem with multiple images in a JSP (Connection reset by peer)
          843835
          I am also getting java.lang.OutOfMemoryError exceptions in addition to the connection reset by peer ones.

          2002-09-05 13:37:24 StandardWrapperValve[DisplayXwd]: Servlet.service() for servlet DisplayXwd threw exception
          javax.servlet.ServletException: Servlet execution threw an exception
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
               at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
               at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
               at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
               at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
               at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
               at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
               at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
               at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
               at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
               at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
               at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
               at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
               at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
               at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
               at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
               at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
               at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
               at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
               at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
               at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
               at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
               at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
               at java.lang.Thread.run(Thread.java:536)
          ----- Root Cause -----
          java.lang.OutOfMemoryError