• JAVA Web知识点整理(四)


    ServletResponse父接口

    (1)字节流和字符流相关的方法  

       ServletOutputStream getOutputStream()   //获取输出字节流对象
     
       PrintWriter getWriter()             //获取输出字符流对象

    (2)响应头相关的方法

       void setContentLength(int len)           //设置响应长度
              
       void setContentType(String type)        //设置响应类型     常用

    HttpServletResponse子接口---封装响应信息,对应JSP的response内置对象

       void addCookie(Cookie cookie)           //添加Cookie    常用
    
       void addHeader(String name, String value)     //添加指定名-值的响应头
     
       boolean containsHeader(String name)        //判断是否包含指定名称的响应头
    
       String encodeUrl(String url)              //为了实现会话跟踪,在URL末尾添加JSessionID            
     
       void sendRedirect(String location)         //客户端重定向      常用   
       
       void setHeader(String name, String value)     //设置指定名-值的响应头
             
       void setStatus(int sc)               //设置响应状态码

    典型的HTTP响应状态码

    static int SC_OK        // Status code (200) indicating the request succeeded normally.

    static int SC_NOT_FOUND   // Status code (404) indicating that the requested resource is not available.

    static int SC_FORBIDDEN   // Status code (403) indicating the server understood the request but refused to fulfill it.

    static int SC_INTERNAL_SERVER_ERROR  // Status code (500) indicating an error inside the HTTP server which prevented it from fulfilling the request.


  • 相关阅读:
    js学习笔记
    在 Windows 下远程桌面连接 Linux XManager 篇
    使用多种反病毒引擎扫描文件
    光纤接口小知识
    在 Windows 下远程桌面连接 Linux VNC 篇
    基于 RHEL 的 CentOS 5.5 发布
    安装Windows 7的XP模式的步骤
    跨平台加密版 SQLite 3 wxSQLite3
    Free 的迷思
    使用 iptables 限制黑客猜密码
  • 原文地址:https://www.cnblogs.com/sheng-se/p/14376448.html
Copyright © 2020-2023  润新知