jsp里用out.print("aaaa")有异常怎么处理?
我在jsp 里用<%
...
out.print("<script language='javascript'>alert(验证码错误!);window.location='login';return false;");
....
%>
一直抛出异常 说与什么OutputStream 冲突,请问这个要怎么处理 啊?
谢谢!
具体异常提示如下:
2008-2-11 9:44:06 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet debugjsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:596)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:186)
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.image_jsp._jspService(org.apache.jsp.image_jsp:122)
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:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
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.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
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:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
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)
[[it] 本帖最后由 yanhaolang 于 2008-2-11 09:44 编辑 [/it]]
搜索更多相关主题的帖子:
aaaa print jsp
----------------解决方案--------------------------------------------------------
请斑竹过来帮我 看看,这个要怎么办 啊?
----------------解决方案--------------------------------------------------------
你这可以用一个JS来写就OK了
----------------解决方案--------------------------------------------------------
[bo]以下是引用 [un]doughty[/un] 在 2008-2-11 10:39 的发言:[/bo]
你这可以用一个JS来写就OK了
你这可以用一个JS来写就OK了
我这就是用一个js来写的,不懂你 的意思。。。请明示。
----------------解决方案--------------------------------------------------------
问题我已经解决了,呵呵。。。发现不是javascript的问题。而是
OutputStream output=response.getOutputStream();
ImageIO.write(image,"JPEG",output); 的问题,会抛出异常,
但是 奇怪捕获不了。。。
我在后面加上
output.flush();
output.close();
out.clear();
out = pageContext.pushBody();
就正常了。。。不知道 有没有朋友遇到我这个问题。。
----------------解决方案--------------------------------------------------------
你的代码有问题: out.print("<script language=javascript>window.location='login.jsp';return false;</script>");
----------------解决方案--------------------------------------------------------