1.jsp&el表达式
1.1 jsp+java
<%!定义成员变量%>
<%=输出内容(变量、字符串)%>
<% 写java代码 —— service()%>
1.2 el表达式
${entity}
servletContext.setAttribute("JINAN","03");
request.setAttribute("JINAN","02");
${JINAN} //02
${applicationScope.JINAN}
${requestScope.JINAN}
2.cookie
//
Cookie[] cookies = request.getCookies();//Cookie[]
Cookie cookie = find();
cookie.getName();
cookie.getValue();
c = new Cookie(name,value);
response.addCookie(c);
//设置时长
cookie.setMaxAge(int seconds);
//设置路径
cookie.setPath(); //补充:单点登录 在网站1是登录状态,那么当我去登录网站2的时候,不需要再次登录,就是登录状态
//销毁
1)Cookie newCookie = new Cookie(name,"");
2)newCookie.setMaxAge(0);
3)newCookie.setPath();
3)response.addCookie(newCookie);
//浏览记录案例-清空浏览记录
3.session
3.1 创建(取得)
HttpSession session = request.getSession();
3.2 域对象
一次会话(浏览器打开——不停访问服务——关闭)
session.setAttribute();
session.getAttribute();
3.3 销毁
1)session.invalidate();
2)自然跪 conf/web.xml:
<session-config>
<session-timeout>30</session-timeout>
</session-config>
3)爆头 非法关闭——提前预备该问题的处理方案
1.1 jsp+java
<%!定义成员变量%>
<%=输出内容(变量、字符串)%>
<% 写java代码 —— service()%>
1.2 el表达式
${entity}
servletContext.setAttribute("JINAN","03");
request.setAttribute("JINAN","02");
${JINAN} //02
${applicationScope.JINAN}
${requestScope.JINAN}
2.cookie
//
Cookie[] cookies = request.getCookies();//Cookie[]
Cookie cookie = find();
cookie.getName();
cookie.getValue();
c = new Cookie(name,value);
response.addCookie(c);
//设置时长
cookie.setMaxAge(int seconds);
//设置路径
cookie.setPath(); //补充:单点登录 在网站1是登录状态,那么当我去登录网站2的时候,不需要再次登录,就是登录状态
//销毁
1)Cookie newCookie = new Cookie(name,"");
2)newCookie.setMaxAge(0);
3)newCookie.setPath();
3)response.addCookie(newCookie);
//浏览记录案例-清空浏览记录
3.session
3.1 创建(取得)
HttpSession session = request.getSession();
3.2 域对象
一次会话(浏览器打开——不停访问服务——关闭)
session.setAttribute();
session.getAttribute();
3.3 销毁
1)session.invalidate();
2)自然跪 conf/web.xml:
<session-config>
<session-timeout>30</session-timeout>
</session-config>
3)爆头 非法关闭——提前预备该问题的处理方案