In the JSP:
1 // Get 2 request.getsession (). SetAttribute ("username", "xxx"); // Set
In Java:
1 //in the servlet2 request.getsession ();3Session.getattribute ("username");4Session.setattribute ("username", "xxx");5Session.setmaxinactiveinterval (30*60);6 session.invalidate ();7 8 //Method 1 in Struts9Servletactioncontext.getrequest (). GetSession (). SetAttribute ("username", "xxx");TenServletactioncontext.getrequest (). GetSession (). getattribute ("username"); OneServletactioncontext.getrequest (). GetSession (). Setmaxinactiveinterval (30*60); A servletactioncontext.getrequest (). GetSession (). invalidate (); - - //Method 2 in Struts theActioncontext.getcontext (). GetSession (). Put ("username", "xxx"); -Actioncontext.getcontext (). GetSession (). Get ("username"); -Actioncontext.getcontext (). GetSession (). Clear ();
Web. xml:
1 < Session-config > 2 < Session-timeout ></session-timeout> 3</ Session-config >
In Tomcat-->conf-->conf/web.xml:
1 < Session-config > 2 < Session-timeout ></session-timeout>3</ Session-config>
Summary: Priority comparisons, written in Java, are higher than in Web. Xml.
The session operation in Java EE