不知道为什么,在写servlet的时候总是出现标题这样的错误,
2009-10-8 20:26:11 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet CommonReceiveParamterServlet threw exception
java.lang.IllegalStateException: Cannot forward after response has been committed
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:312)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at edu.bjtu.newBean.servlet.CommonReceiveParamterServlet.doPost(CommonReceiveParamterServlet.java:345)
at edu.bjtu.newBean.servlet.CommonReceiveParamterServlet.doGet(CommonReceiveParamterServlet.java:36)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
代码是这样的:
List<Map<String,Object>> orderlist = new ArrayList<Map<String,Object>>();
procedure ="{call SCOTT.processed_total(?)}";
DBUtils dbUtils = new DBUtils();
try {
orderlist = dbUtils.executeProcedureWithOutInputParamter(procedure);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}//orderlist用来判断结果集是不是为空!
if(orderlist.size()==0){
request.setAttribute("error","noJgcpGN"); request.getRequestDispatcher("err/noData.jsp").forward(request, response);
}
request.setAttribute("orderlist", orderlist);
request.getRequestDispatcher("jgcp/jgcp/jgcpGN.jsp").forward(request, response);
就是上述代码,因为对request转发不明白真正的含义引起的,本来以为request.getRequestDispatcher("err/noData.jsp").forward(request, response);后就跳出来servlet,没想到还是会执行下面这一段代码,太大意了,后来debug的时候才看到,
request.setAttribute("orderlist", orderlist);
request.getRequestDispatcher("jgcp/jgcp/jgcpGN.jsp").forward(request, response);
把代码最后加上
else{request.setAttribute("orderlist", orderlist);
request.getRequestDispatcher("jgcp/jgcp/jgcpGN.jsp").forward(request, response);
}
就不会出现这个问题了!
最后的代码为:
List<Map<String,Object>> orderlist = new ArrayList<Map<String,Object>>();
procedure ="{call SCOTT.processed_total(?)}";
DBUtils dbUtils = new DBUtils();
try {
orderlist = dbUtils.executeProcedureWithOutInputParamter(procedure);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(orderlist.size()==0){
request.setAttribute("error", "noJgcpGN");
request.getRequestDispatcher("err/noData.jsp").forward(request, response);
}else{
request.setAttribute("orderlist", orderlist);
request.getRequestDispatcher("jgcp/jgcp/jgcpGN.jsp").forward(request, response);
}
问题解决!
分享到:
相关推荐
NULL 博文链接:https://m635674608.iteye.com/blog/1510545
prerequisite patches in an unstable way, which has been updated to compute in a way that is compatible with "git patch-id --stable". * The "git log" command by default behaves as if the --mailmap ...
These dummy transactions get committed when everything is idle (after there has been some activity).
Response already committed 删除websphere时,直接删除安装目录下的文件,重新安装websphere时会提示websphere已安装,是否安装副本。 WebSphere应用更新问题 配置oracle jdbc连接时,控制台测试连接成功,但应用...
Section=ResponseHeader Detail=CR 后面必须是 LF The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF 主体意思是微软没有容忍不符合RFC 822...
开源项目-golang-go.zip,"eliminate GOMAXPROCS limit" has just been committed to the master branch.
55 Read Committed隔离级别是如何基于ReadView机制实现的?l.pdf
PostgreSQL offers three levels of transaction isolation: Read Committed
Number of committers has been determined by going through CVS logs from January 1st, 2004 to December 31st, 2004 and contributors by going through the list of contributions and problem reports. ...
FO承诺-CFT协议-范围证明(英语论文)
curl for windows10 x64 , version Version 7.56.1 (23 Oct 2017) Daniel Stenberg (23 Oct 2017) - RELEASE-NOTES: 7.56.1 ...- imap: if a FETCH response has no size, don't call write callback
NEW *-在侧面菜单中添加了Committed源代码的链接,以便任何有兴趣的人都可以参与! 更新3.0.2-您现在可以选择将待办事项存储在本地存储或Chrome存储中-漏洞修复更新3.0.1-创建待办事项列表-添加待办事项的链接-...
svn关键词BASE, HEAD, COMMITTED, PREV的深入理解.rar
released the first version of the XtraGrid Suite, our focus has been to deliver ground-breaking new capabilities for Visual Studio .NET®. With XtraGrid Suite v2, you have at your disposal a ...
Returns a boolean indicating whether the named response header has already been set. contextDestroyed(ServletContextEvent) - Method in interface javax.servlet.ServletContextListener Notification ...
Everybody in the industry is committed to AJAX. Everybody understands the impact of it. Everybody recognizes the enormous power that can be derived from its employment in real-world solutions. Very ...
If you attempt to access a reserved address that has not yet been committed (backed by memory or disk) you will cause an access violation. Committed Memory Committed pages are those pages that when ...