This article mainly introduces JSP to get action from the session and session empty and judge, need friends can refer to the following
JSP gets the session value from the action there are several ways: For example, I have a session in the action ("SessionID", "Sessionvalue") I. Get with struts tag: <s:property value= "#session. SessionID"/> II, <%=request.getsession.getattribute (" SessionID ");> session is also one of the built-in objects, you can use the session directly, more convenient than request.getsession can also be written <%=session.getattribute (" SessionID ");> III, El expressions get:${sessionscope.sessionid} If the value is assigned to a bean, it is the same, similar to the ${ sessionscope.bean.beanproperty} General Session time is 30 minutes if the session is judged to exist code as follows: <% String id = ""; String username = ""; User user = (User) session.getvalue ("Docuser"); //Judge U Whether the ser is empty, and if not NULL, the following. Otherwise, a null pointer exception is reported. if (user!= null) { id = user.getid (); username = user.getusername (); } %> &N Bsp You can also empty session to get to the session and then set his value to null code as follows: <% lduser lduser = (lduser) Actioncontext.getcontext (). GetSession (). Get ("Lduser"); if (lDuser = = null) { session.putvalue ("Lduser", null); Out.println ("session to close"); %>