林恒山
Session的作用范围:一次会话
创建:服务器第一次调用getSession()创建Session
销毁:三种情况销毁Session:
1.session过期. 默认过期时间为30分钟.
2.非正常关闭服务器.如果正常关闭session序列化到硬盘.
3.手动调用session.invalidate();
Session是一个域对象.存取数据和移除数据跟其他域对象调用的方法一样.但是Session数据是存在服务器端的.
JSP脚本:
<%! %> servlet实现类的成员部分,可以定义变量/方法/类
<% %> service()内部的内容,可以定义变量/类
<%= %> service()内部的out.print().
JSP内置对象:就是在jsp内可以直接使用的对象
request HttpServletRequest getParameter(),setAttribute(String name,Object value);
response HttpServletResponse setHeader(String name,String value);getOutputStream();getWriter();
session HttpSession setAttribute();getAttribute();
application ServletContext setAttribute();getAttribute();
page Object toString();wait();
pageContext PageContext setAttribute();getAttribute();
config ServletConfig getServletName();getServletContext();
out JspWriter write(),print();
exception Throwable getMessage(),getCause(); 设置isErrorPage=”true”
JSP的四个域范围:
PageScope :当前页面中有效. pageContext PageContext
RequestScope :一次请求范围. request HttpServletRequest
SessionScope :一次会话范围. session HttpSession
ApplicationScope :应用范围 application ServletContext |