`
123003473
  • 浏览: 1060235 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

response.isCommitted()

 
阅读更多
HelloServlet类的service()方法最后调用PrintWriter对象的close()方法关闭底层输出流,该方法在关闭输出流之前会先把缓冲区内的数据提交到客户端。因此在调用PrintWriter 对象的 close()方法之前,response.isCommitted()方法返回 false;而在调用PrintWriter对象的close()方法之后,response.isCommitted()方法返回true。HelloServlet类的service()方法中的“System.out.println(…)”语句把内容打印到Tomcat服务器所在的控制台。
分享到:
评论

相关推荐

    关于JSP的学习经验总结

    `response.isCommitted()`方法用来检查是否已经将数据发送到客户端。 【服务端重定向】 重定向分为以下三种方式: 1. **使用`response.sendRedirect()`**:此方法修改HTTP响应头,告诉浏览器加载新的URL,实现...

    解决Struts2中下载文件时点击取消按钮后台报错问题

    在读取文件并写入输出流的过程中,我们检查`ServletResponse`是否已提交(`isCommitted()`)以及`ServletOutputStream`是否已被关闭(`isClosed()`)。如果任一条件满足,就立即跳出循环,避免不必要的数据传输和...

    JSP学习笔记

    还可以使用`response.isCommitted()`方法来检查数据是否已经被输出到客户端,如果返回`true`表示已经输出,`false`表示尚未输出。 #### 三、服务端输出重定向 - **使用`response.sendRedirect(String url)`**:这...

    分享JSP学习经验总结

    可以通过`response.setBufferSize()`设置缓冲区大小,或者检查`response.isCommitted()`来判断数据是否已发送到客户端。 ### 三、服务端输出重定向 1. **`response.sendRedirect()`**:通过修改HTTP头部,让浏览器...

    java.lang.IllegalStateException: Cannot call sendError() after the response has

    4. **使用HttpServletResponse.isCommitted()**:在调用`sendError()`之前,可以先检查响应是否已被提交。如果是,则不应该再尝试发送错误。 5. **在异常发生时记录详细日志**:捕获到`IllegalStateException`后,...

    response jsp 中的重要知识点

    `resetBuffer()`可以清空缓冲区,`isCommitted()`检查是否已提交响应。 9. **关闭响应** 一旦响应被提交,就不能更改。但可以通过`reset()`来清除所有设置,使响应回到初始状态。然而,一旦客户端开始接收数据,就...

    servlet2.4doc

    The doFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. doGet...

    a project model for the FreeBSD Project.7z

    While no-one takes ownership of FreeBSD, the FreeBSD organisation is divided into core, committers and contributors and is part of the FreeBSD community that lives around it. Figure 3-1. The FreeBSD ...

    大学英语选择题61道与答案解析.doc

    6. be committed to doing sth. 表示“致力于做某事”,符合句意。conducted 表示“进行,实施”;concentrated 表示“集中”;concerned 表示“关心,关注”。答案是 B. committed。 7. will not have sb. doing ...

    jQwidgets 3.6.0

    We are committed to supporting all new versions of jQuery and ensuring the highest level quality. At present, we highly recommend that you use jQuery 1.11.1. This version is stable, high quality, and...

    (最新)大学英语选择题61道及答案.pdf

    6. "be committed to"表示“致力于,投身于”。答案:B。 7. "have sb. doing sth."表示不允许某人做某事,强调持续性动作。答案:C。 8. "in response to"意为“回应,响应”。答案:D。 9. "criticize sb. for ...

    Apache Solr [Apache Con 2006]

    Changes made to the index must be committed before they become visible. The `<commit/>` command finalizes changes, closes the `IndexWriter`, removes duplicates, opens a new `IndexSearcher`, and ...

    [4] 学位英语:核心词汇(四).doc

    268. **commit** - 犯(错误,罪行等),干(坏事等):用于表示做出某种行为,如 "He committed a serious mistake during the project." 270. **distinguish** - 区分,辨别:识别不同之处,如 "Can you ...

    curl for windows10 x64

    The 'tip' is the most recent branch committed to, this should be 'default' like the URLs for the browser are. Closes #1998 - imap: if a FETCH response has no size, don't call write callback

    HttpServletRequest与HttpServletResponse的实现类.docx

    - `isCommitted()` 检查响应是否已提交,一旦提交,就不能修改。 7. **设置Cookie**: - `addCookie(Cookie cookie)` 添加Cookie到响应中。 在处理HTTP请求和构建响应时,开发者通常会结合HttpServletRequest和...

    Java常见异常

    11. **java.io.IOException: response already committed** HTTP响应已提交,无法再次修改。确保在HTTP响应被发送给客户端后不再尝试修改它。 12. **java.lang.ClassCastException: org.apache.catalina.util....

    Internetworking IPv6 with Cisco Routers

    Cisco Systems, the premier IP vendor, is committed to the evolution of the Internet/Intranets and considers the next generation IP to be a key component of their growth. It has taken a leadership ...

    Django 1.1 Testing and Debugging.pdf

    Response context and template information 131 Testing transactional behavior 132 Chapter 5: Filling in the Blanks: Integrating Django and Other Test Tools 135 Problems of integration 136 ...

Global site tag (gtag.js) - Google Analytics