A large number of errors are reported in the background when you view Weblogic server logs today, as shown below:
Java.net. protocolexception: didn't meet stated Content-Length, wrote: '000000' bytes instead of stated: '000000' bytes.
At weblogic. servlet. Internal. servletoutputstreamimpl. ensurecontentlength (servletoutputstreamimpl. Java: 470)
At weblogic. servlet. Internal. servletresponseimpl. ensurecontentlength (servletresponseimpl. Java: 1176)
At weblogic. servlet. Internal. servletresponseimpl. Send (servletresponseimpl. Java: 1188)
At weblogic.servlet.internal.servletrequestimpl.exe cute (servletrequestimpl. Java: 2590)
At weblogic.kernel.executethread.exe cute (executethread. Java: 197)
At weblogic. kernel. executethread. Run (executethread. Java: 170)
After multiple tests, find a solution, mainly because when the image is downloaded,
Bis = new bufferedinputstream (Rs. getbinarystream (IMG ));
Response. setcontentlength (Rs. getint (2 ));
Response. setbuffersize (1024 );
Response. setcontenttype ("application/X-msdownload ");
Response. setheader ("content-disposition", "filename =" + infovariable. converu2a ("IMG "));
Servletoutputstream op = response. getoutputstream ();
Byte [] B = new byte [1024];
Int size = 0;
While (size = bis. Read (B ))! =-1)
Op. Write (B, 0, size );
The number of bytes imported to response is not set. You can add the following settings to solve this problem,
// Where Rs. getint (2) is the size of the Blob field in the database, which can be obtained through the dbms_lob.getlength (IMG) Function
Response. setcontentlength (Rs. getint (2); // note that the cotentlength is the image size.
If the image cannot be opened or is garbled, use response. resetbuffer (); refresh the cache.