zoukankan      html  css  js  c++  java
  • 读书笔记Review: HttpServletResponse

    1. You use the Response to send data back to the client
    2. The most common methods you'll call on the response object(HttpServletResponse) are setContentType() and getWriter()
    3. Be careful-many developers assume the method is getPrintWriter(),but it's getWriter()
    4. The getWriter() method lets you do character I/O to write HTML(or something else) to the stream
    5. You can also use the response to set headers,send errors,and add cookies
    6. In the real world,you'll probably use a JSP to send most HTML response,but you may still use a response stram to send binary data(like a JAR file,perhaps) to the client
    7. The method you call on your response for getting a binary stream is getOutputStream()
    8. The setContentType() method tells the browser how to handle the data coming in with the response.Typical content types are "text/html","application/pdf",and "image/jpeg".
    9. You can set response headers using addHeader() or setHeader(). The difference depends on whether the header is already part of the response.If  it is,setHeader() will replace the value,but addHeader will add an additional value to the existing response.If the header is not already part of the response, the setHeader() and addHeader() behave in exactly the same way
    10. If you don't want to respond to a request,you can redirect the request to a different URL.The browser takes care fo sending the new request to the URL you provide
    11. To redirect a request,call sendRedirect(aStringURL) on the response.
    12. You cannot call sendRedirect() after the response is committed! In other words,if you have already written something to the stream,it is too late to do a redirect  
    13. A request redirect is different from a request dispatch.A request dispatch (covered more in another chapter) happens on the server,while a redirect happens on the client.A request dispatch hands the request to another component on the server,usually within the same web app.A request redirect simply tells the browser to go a different URL.

  • 相关阅读:
    【BZOJ2959】—长跑(LCT维护双连通分量+并查集)
    【BZOJ5394】【Ynoi2016】—炸脖龙(树状数组+广义欧拉定理)
    【BZOJ2588】【Spoj10628】—Count on a tree(主席树)
    SCOI2019爆零记+总结反思
    【SCOI2019】—DAY1T1平台跳跃(打表+高精度)
    省选模板复习—【字符串】
    省选模板复习—【数据结构】
    【BZOJ3572】【HNOI2014】—世界树(虚树+倍增+dp)
    python paramiko 模块
    python sys模块
  • 原文地址:https://www.cnblogs.com/yql1986/p/2002232.html
Copyright © 2011-2022 走看看