1.獲取servletContent
? ? ? ? 1. 通過request對象獲取
????????????????request.getServletContext();
????????2. 通過HttpServlet獲取
????????????????this.getServletContext();
? ? ? ? 3.賦值
? ? ? ? ? ? ? ? context.setAttribute(name,value);
? ? ? ? ? ? ? ? removeAttribute(name,value);
????????? ? ? ? repalceAttribute(name,value);??
? ? ? ? 前臺獲裙宰埂:${applicationScope.name}
2.Cookie? ? ?
? ????????????????????????? ?1. 創(chuàng)建Cookie對象惧财,綁定數(shù)據(jù) * new Cookie(String name, String value)
?????????????????????????????2. 發(fā)送Cookie對象 * response.addCookie(Cookie cookie)
?????????????????????????????3. 獲取Cookie,拿到數(shù)據(jù) * Cookie[]? ?request.getCookies() ?? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? 4. setMaxAge? 設(shè)置有效時(shí)間
3.session 設(shè)置有效時(shí)間????????
????????????1.? ? ? ? ?session默認(rèn)失效時(shí)間 30分鐘
????????????????????????????選擇性配置修改
????????????????????????????????<session-config>
? ? ? ? ????????????????????????????????<session-timeout>30</session-timeout>
? ????????????????????????????? </session-config>
? ? ? ????? 2.? ? ? ? 調(diào)用方法? ? setMaxInactiveInterval(int interval)
? ??????
? ??????????