zoukankan      html  css  js  c++  java
  • JSP九大内置对象及其方法

    内置对象包括

    request response pageContext session application out config page exception

    1.out
    (1)clear()清除缓冲区
    (2)flush()刷新缓冲区
    (3)newLine() 创建新的一行
    (4)print(各种数据类型)显示数据内容
    (5)pringln(各种数据类型)换行显示数据内容
    2.request 向服务器发送请求
    (1)getLocale() 获取本地的语言
    (2)getMethod()获取客户端的参数方法 post get
    (3)getParameter(String name)取得传入的参数
    (4)getParameterNames()取得传入参数的名字集合
    (5)getParameterMap()取得传入参数的Map集合 参数名和值
    (6)getRemoteAddr()取得客户端的网络地址
    (7)getServerName()取得服务器的名字
    (8)getServletPath()获取servlet的路径
    (9)setCharacterEncoding(String s)设置传入参数的字符集

    3.response
    (1)addCookie(Cookie cookie)
    (2)sendRedirect()重定向
    (3)setBufferSize()设置缓存大小
    (4)setContentType()设置客户端的编码机制
    (5)setLocale()设置客户端的语言
    (6)getWrite()取得内容输出器

    4.session 会话
    (1)getAttribute()根据名字取得session的参数值
    (2)getAttributeName() 获取session的参数名
    (3)getCreationTime()取得session的创建时间 客户端的访问服务器的时间
    (4)getId()获取客户端的id
    (5)getLastAccessTime() 获取客户最后一次访问服务器的时间
    (6)getMaxInactiveInterval() 客户端停止访问后在服务器的保存时间
    (7)isNew() 判断客户端是否是第一次访问服务器
    (8)removeAttribute()删除session的参数
    (9)setAttribute()设置session的参数
    (10)setMaxInactiveInterval() 设置客户端停止访问后在服务器的保存时间
    5.application 应用
    (1)getAttribute()根据名字取得application的参数值
    (2)getAttributeName() 获取application的参数名
    (3)setAttribute()设置application的参数
    (4)getMajorVersion()取得服务器支持servlet的版本号
    (5)removeAttribute()删除application的参数
    6.config 配置
    (1)getInitParameter()根据名字获取初始化参数值
    (2)getInitParameterNames()取得初始化参数名字
    7.pageContext 上下文对象
    (1)forward()将客户的请求移动到另一个jsp文件
    (2)getAttribute(String name,int scope)根据参数的名字和作用域取得参数值
    (3)getAttributeNamesInScope(int scope)取得某个作用域参数名
    (4)removeAttribute(String name,int scope)根据参数的名字和作用域删除参数
    (5)setAttribute(String name,Object o,int scope)根据参数的名字和作用范围创建参数
    (6)getException()取得exception对象
    (7)getOut()取得out对象
    (8)getPage()取得page对象
    (9)getRequest()取得request对象
    (10)getResponse()取得response对象
    (11)getSession()取得session对象
    (12)include()在jsp文件中包含其他文件
    (13)getServletContext()取得application对象
    8.exception 异常
    (1)getLocalizedMessage()取得异常信息
    (2)getMessage()取得详细的异常信息
    (3)printStackTrace() 在服务器端显示异常信息
    (4)toString() 显示异常类和信息
    9.page

    该对象的实质就是java.lang.Object,在JSP文件内没有实质的应用

  • 相关阅读:
    docker命令总结
    VulToEs
    MYSQL
    MoonStack
    Spring mvc json null
    MySQL
    极光推送
    坑爹的RockSaw和坑爹的windows7
    App接口设计思路
    CSUOJ 1329 一行盒子(数组模拟链表)
  • 原文地址:https://www.cnblogs.com/lm970585581/p/7158065.html
Copyright © 2011-2022 走看看