application(severlet context)
創(chuàng)建——ServletContext name=this.getServletContext();
賦值——name.setAttribute("名","值");
獲取值——name.getAttribute("名");
移除——name.removeAttribute("名");
更改值——name.replaceAttribute("名");
前臺獲取值——${applicationScope.屬性名}
Cookie
創(chuàng)建——Cookie cook=new Cookie();
傳遞——response.addCookie("cook");cook是添加到瀏覽器對象內的,只要是本瀏覽器內的頁面都可以得到這個cookie
獲得cookie——request.getCookies();此方法獲得一個cookie集合,通過下標獲取特定cookie
設置cookie有效時間——setMaxAge(以秒為單位);
設置session的有效時間——setMaxInactiveInterval(秒);
在pom文件中設置對標簽session timeout——以分鐘為單位
session是依據(jù)請求刷新有效時間,cookie一般用以長期保存數(shù)據(jù),cookie如果不設置最大有效時間,則默認有效期是session,即瀏覽器關閉后則消失
jsp界面設置屬性
①userBean
②setPorpertity
③getPorpertity