,在调用的时候直接在jsp或者servlet里面使用session.getAttribute('name',id)取得属性,当然需要在用户登录或者网页加载的时候进行一次初始化,给他一个属性。然后就可以在不同的servlet中直接调用。
Session session=req.getSession();
就这一句话就行了,剩下的容器都帮你做完了。
session是在服务器端的,靠的sessionID来识别。
String usercode = (String)request.getSession().getAttribute("usercode");
HttpSession session = request.getSession();
String str=""+request.getSession().getAttribute("name");