title: org.apache.derby.client.am.CloseFilterInputStream
body: <p>Sr I am new with derby, When I try to test display a Blob field in database, and this display "org.apache.derby.client.am.CloseFilterInputStream" .</p>
  
  <pre><code>        response.setContentType("image/jpeg");
      ServletOutputStream out = response.getOutputStream();
      for (Images o : IM.getAllImages()) {
          InputStream is = o.getImg();
          byte[] imageBytes = getBytes(is);
          out.write(imageBytes);
          response.setContentLength(imageBytes.length);
          response.getOutputStream().write(imageBytes);
          out.close();
      }
  </code></pre>
  
  <p>Also, when i try this code,This error come up "java.io.IOException: The object is already closed.". Do I missing something ?
  <a href="https://i.stack.imgur.com/JySjq.png" rel="nofollow noreferrer">error</a></p>
  
  <p>This is Method to covert InputStream to byte array</p>
  
  <pre><code>    public static byte[] getBytes(InputStream is) throws IOException {
  
      int len;
      int size = 1024;
      byte[] buf;
  
      if (is instanceof ByteArrayInputStream) {
          size = is.available();
          buf = new byte[size];
          len = is.read(buf, 0, size);
      } else {
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          buf = new byte[size];
          while ((len = is.read(buf, 0, size)) != -1) {
              bos.write(buf, 0, len);
          }
          buf = bos.toByteArray();
      }
      return buf;
  }
  </code></pre>
  
  <p>My doGet 
  DisplayImagesController.java</p>
  
  <pre><code>    @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      ServletOutputStream out = response.getOutputStream();
      response.setContentType("image/jpeg");
      for (Images o : IM.getAllImages()) {
          InputStream is = o.getImg();
          byte[] imageBytes = getBytes(is);
          out.write(imageBytes);
          response.setContentLength(imageBytes.length);
          response.getOutputStream().write(imageBytes);
  
      }
      out.close();
  }
  </code></pre>
  
  <p>and Display</p>
  
  <pre><code>        &lt;table width="70%" border="1"&gt;
          &lt;tr&gt;
              &lt;th&gt;id&lt;/th&gt;
              &lt;th&gt;IMG&lt;/th&gt;
              &lt;th&gt;IMG Name&lt;/th&gt;
              &lt;th&gt;UserID&lt;/th&gt;
  
              &lt;th colspan="2"&gt;Action&lt;/th&gt;
          &lt;/tr&gt;
          &lt;c:forEach items="${imgs}" var="img"&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;c:out value="${img.id}"/&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;c:out value="${img.imgName}"/&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;img src="DisplayImagesController" width="200" height="100"/&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;c:out value="${img.userID}"/&gt;&lt;/td&gt;
  
              &lt;/tr&gt;
          &lt;/c:forEach&gt;
  
      &lt;/table&gt;
  </code></pre>
  
  <p>But the images dont display</p>