81,116
社区成员
发帖
与我相关
我的任务
分享
servlet实例中压根没有request、response,destory想释放估计心有余而力不足,也不要指望在destory里关闭response,他压根不是干这个用的。
我测试用的是tomcat7.0,resoponse如果没有关闭,tomcat会自动关闭
org.apache.catalina.core.ApplicationDispatcher.doForward(ServletRequest request, ServletResponse response)方法
最后一段代码是
// Close anyway
try {
PrintWriter writer = response.getWriter();
writer.close();
} catch (IllegalStateException e) {
try {
ServletOutputStream stream = response.getOutputStream();
stream.close();
} catch (IllegalStateException f) {
// Ignore
} catch (IOException f) {
// Ignore
}
} catch (IOException e) {
// Ignore
}
可以清楚看到不管你有没有关闭,tomcat都重新关闭了一次