开发者社区> 问答> 正文

Servlet failed with IOException java.io.?报错

将web程序从tomcat移到weblogic中验证码无法显示:

查看日志发现报错:

<> <> <1389665691275> <BEA-101019> <[ServletContext@17320663[app:dbCenter-web module:dbCenter-web.war path:/dbCenter-web spec-version:2.5]] Servlet failed with IOException

java.io.IOException: response already committed
at weblogic.servlet.jsp.JspWriterImpl.clear(JspWriterImpl.java:82)
at jsp_servlet.__image._jspService(__image.java:172)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

jsp部分代码如下:

OutputStream output = response.getOutputStream();   
 
// 输出图象到页面   
ImageIO.write(image, "JPEG", output);   
output.flush();
output.close();

out.clear();   
out = pageContext.pushBody();   

查阅网上资料有人说去掉

out.clear();   
out = pageContext.pushBody(); 

但是如果去掉的话,在tomcat中报错。

查看weblogic.jar的源码JspWriterImpl:

public void clear() throws IOException {
if (this.response.isCommitted()) {
throw new IOException("response already committed");
}
this.co.clearBuffer();
}


public void clearBuffer() throws IOException {
this.co.clearBuffer();
}

于是将out.clear改为out.clearBuffer(),weblogic下不再报错

但验证码还是无法显示,请教?

展开
收起
爱吃鱼的程序员 2020-06-22 13:20:52 1723 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    已解决怎么解决的

    2020-06-22 13:21:11
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
多IO线程优化版 立即下载