毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> java技术 >> 正文

java.lang.IllegalStateException:   getOutputStream()   has   already   been   called   for   this   response

更新时间:2012-5-18:  来源:毕业论文


这种异常信息在百度里搜索时都能找到,但是对于我遇到的却不是他们的那种情况:
+com.swc.se.controller     ---处理来自游览器的控制器类
-com.swc.se.controller.mobile     ---处理来自手机的控制器类
  +ConsumerLogin.java   ---处理来自手机的用户登录判断
程序片段:
public   void   doPost(HttpServletRequest   request,   HttpServletResponse   response)
throws   ServletException,   IOException   {
//   处理来自手机的登录
response.setContentType( "text/html;   charset=GBK ");
InputStream   is   =   null;
String     name= " ";
String   password= " ";
is   =   request.getInputStream();
DataInputStream   dis   =   new   DataInputStream(is);
name=dis.readUTF();
password=dis.readUTF();
//   对接收的参数进行处理
                                    //下面的Model层的代码跟JSP作为客户端调用的是一样的
ConsumerService   consumerService=new   ConsumerService();
Consumer   consumer=new   Consumer();
consumer.setNickname(name);
consumer.setPassword(password);
DataOutputStream   dos   =   null;
        ServletOutputStream   servletOutputStream=response.getOutputStream();
dos   =   new   DataOutputStream(servletOutputStream);
Boolean   isLoginSucc=consumerService.login(consumer);
//如果登录成功的话:
if   (isLoginSucc){
System.out.println( "登录成功 ");
dos.writeUTF( "success ");
}
//如果登录失败的话:
else   {
System.out.println( "登录失败 ");
dos.writeUTF( "failure ");

}
}

现在遇到的异常信息是:
对于手机那边的是:java.io.EOFException
                at   java.io.DataInputStream.readFully(+48)
                at   java.io.DataInputStream.readUTF(+30)
      at   java.io.DataInputStream.readUTF(DataInputStream.java:522)
                at   com.swc.se.SeClient.Logic.SeClientLoginThread.run(SeClientLoginThread.java:60)

对于Web服务器这边的是:
2007-3-25   13:33:57   org.apache.catalina.core.ApplicationDispatcher   invoke
严重:   Servlet.service()   for   servlet   jsp   threw   exception
java.lang.IllegalStateException:   getOutputStream()   has   already   been   called   for   this   response
at   org.apache.catalina.connector.Response.getWriter(Response.java:599)
at   org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:195)
at   org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:124)
at   org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:117)
at   org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:191)
at   org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:115)
at   org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75)
at   org.apache.jsp.error_jsp._jspService(error_jsp.java:139)
at   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at   org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at   org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:465)
at   org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at   org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at   org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:363)
at   org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:212)
at   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:134)
at   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at   org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at   org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at   org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at   org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at   java.lang.Thread.run(Thread.java:595)

2007-3-25   13:33:57   org.apache.catalina.core.StandardHostValve   custom
严重:   Exception   Processing   ErrorPage[exceptionType=com.swc.se.exception.SeDAOException,   location=/error.jsp]
org.apache.jasper.JasperException:   getOutputStream()   has   already   been   called   for   this   response
at   org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
at   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
at   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at   org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at   org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:465)
at   org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at   org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at   org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:363)
at   org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:212)
at   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:134)
at   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at   org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at   org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at   org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at   org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at   java.lang.Thread.run(Thread.java:595)

也就是说,现在如果手机里用户输入的登录信息是正确的,那么就不会抛出此异常信息,而如果用户输入的信息不对,那么在Model层里的那段代码:
  if(!JDBCUtil.verifyObject(sql)){
  throw   new   SeDAOException( "您输入的用户名与密码不正确,请重新输入! ");
  }
就会抛出系统自定义异常信息,然后转到error.jsp页面,但是这时候并不是在浏览器里执行时出现的异常,而是来自手机端的啊:
2007-3-25   13:33:57   org.apache.catalina.core.StandardHostValve   custom
严重:   Exception   Processing   ErrorPage[exceptionType=com.swc.se.exception.SeDAOException,   location=/error.jsp]
org.apache.jasper.JasperException:   getOutputStream()   has   already   been   called   for   this   response

应该是J2me对重定向支持不够吧
如果你用wap浏览器似乎没问题,但是在J2me里处理就麻烦了点

用ssh做网站的时候遇到过这种情况,当时是用PrintWriter   getWriter()来实现的,这个原因倒是没有去理会它了,应该是父类的问题

加上return就可以了

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。