On Dec 23, 2006, at 4:06 AM, [EMAIL PROTECTED] wrote:
* src/test/java/org/apache/speedyfeed/test/BasicTest.java
  (BasicServlet.doGet): Remember to close the stream.
(...)
@@ -57,8 +59,12 @@
       byte buffer[] = new byte[1024];
       int len;

-      while ((len = in.read(buffer)) != -1) {
-        out.write(buffer, 0, len);
+      try {
+        while ((len = in.read(buffer)) != -1) {
+          out.write(buffer, 0, len);
+        }
+      } finally {
+        out.close();
       }
     }
   }

Just FYI, in servlets, IIRC (not done servlets in a while, perhaps someone can confirm my rusty memory) it is usually better to not flush () or close() any container-provided output stream. This allows the servlet container to do various things better (like http pipes, post request filters, ...); I do know it matters with WebLogic.

The servlet container is required to close the stream appropriately by the servlet spec.

cheers,

/LSD


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to