如何在jsp中设置会话变量

时间:2014-11-27 11:47:38

标签: jsp

编辑文件web.xml会话超时值

<session-config>
        <session-timeout>
            30
        </session-timeout>
</session-config>

1 个答案:

答案 0 :(得分:1)

要在session中设置变量,您无需修改​​Web.xml

HttpSession session = request.getSession();
String al="am session variable"
session.setAttribute("al", al);

要访问它,您只需执行${sessionScope.al}

即可

阅读How do you store Java objects in HttpSession?