WEB项目中如何清除session中某一变量

seesion.setAttribute("objectName1",object1);
seesion.setAttribute("objectName2",object2);

如何清除session中objectName1变量,而不影响session中上的object2变量。

即当调用session.getAttribute("objectName1")时返回null对象,调用session.getAttribute("objectName2")得到object2变量

[code="java"]session.removeAttribute("objectName1");[/code]

session.removeAttribute("objectName1");

如果要清除所有 就用session.invalidate();

session.removeAttribute("session中变量名");