jsp:
request.getSession().setAttribute("username", "xxx"); // 设置
(String)request.getSession().getAttribute("username"); // 获取
${use} rname// 获取
java:
//servlet
request.getSession();
session.getAttribute("username");
session.setAttribute("username", "xxx");
session.setMaxInactiveInterval(30*60);
session.invalidate();
//struts
ActionContext.getContext().getSession().put("username", "xxx");
ActionContext.getContext().getSession().get("username");
ActionContext.getContext().getSession().clear();
web.xml:
<session-config>
<session-timeout>30</session-timeout>
</session-config>
在tomcat-->conf-->conf/web.xml中设置Session超时时间:
<session-config>
<session-timeout>30</session-timeout>
</session-config>