Mantis - Resin
Viewing Issue Advanced Details
1067 major random 04-20-06 15:47 05-24-07 11:37
cornwellsb  
ferg  
normal  
closed 3.0.18  
fixed  
none    
none 3.1.2  
0001067: IllegalStateException content-length exception
I am getting an exception when writing a gif image using a jsp page

I am assuming it is related to this but although I am using 3.0.18 which it says it is fixed in http://bugs.caucho.com/view.php?id=818 [^]

Actually i cannot seem to reproduce this always

[18:24:54.333] java.lang.IllegalStateException: http://chicagoapartmentfinders.netlert.com/proactive/page_config_loader.jsp: [^] tried to write 162 bytes with content-length 43 (At char=60).
[18:24:54.333] at com.caucho.server.connection.ResponseStream.lengthException(ResponseStream.java:551)
[18:24:54.333] at com.caucho.server.connection.ResponseStream.setBufferOffset(ResponseStream.java:362)
[18:24:54.333] at com.caucho.vfs.i18n.ISO8859_1Writer.write(ISO8859_1Writer.java:122)
[18:24:54.333] at com.caucho.server.connection.ToByteResponseStream.flushCharBuffer(ToByteResponseStream.java:469)
[18:24:54.333] at com.caucho.server.connection.ToByteResponseStream.write(ToByteResponseStream.java:321)
[18:24:54.333] at com.caucho.server.connection.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:68)
[18:24:54.333] at java.io.OutputStream.write(OutputStream.java:58)
[18:24:54.333] at _jsp._proactive._page_0config_0loader__jsp._jspService(_page_0config_0loader__jsp.java:4259)
[18:24:54.333] at com.caucho.jsp.JavaPage.service(JavaPage.java:60)
[18:24:54.333] at com.caucho.jsp.Page.pageservice(Page.java:570)
[18:24:54.333] at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:159)
[18:24:54.333] at com.caucho.filters.GzipFilter.doFilter(GzipFilter.java:218)
[18:24:54.333] at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
[18:24:54.333] at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:209)
[18:24:54.333] at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:178)
[18:24:54.333] at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
[18:24:54.333] at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)
[18:24:54.333] at com.caucho.server.port.TcpConnection.run(TcpConnection.java:389)
[18:24:54.333] at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:492)
[18:24:54.333] at com.caucho.util.ThreadPool.run(ThreadPool.java:425)
[18:24:54.333] at java.lang.Thread.run(Thread.java:595)


Im not sure if this is me or the bug is still there but I load a gif image into a byte array with the following code

byte [] bytes = getDefaultImage();
System.out.println("Returning Image Size:" + bytes.length);
response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
response.setHeader("Pragma", "no-cache"); //HTTP 1.0
response.setDateHeader("Expires", 0); //prevents caching at the proxy server
response.setContentLength(bytes.length);
response.setContentType("image/gif");
OutputStream os = response.getOutputStream();
os.write(bytes);
os.close();
response.setContentLength(bytes.length);




Notes
(0001320)
ferg   
06-27-06 13:46   
jsp/0510

You should be able to work around this by avoiding any extra characters before and after your servlet block. (Actually, it's probably just best to use a servlet instead of a JSP.)
(0001952)
ferg   
05-24-07 11:37   
jsp/0510