Consider the following doGet method code of a
servlet:
public void doGet(HttpServletRequest req, HttpServletResponse res)
{
String command = req.getParameter("command");
if("remove".equals(command))
{
HttpSession session = req.getSession();
//insert code here
}
}
If the command equals remove, you want to remove all the attributes from the session. Which of the following options will you use?
Select 1 correct option.
a session.unbind();
b session.invalidate();
c session.expunge();
d session.removeAll();
e Enumerate the attribute names and remove them one by one from the session using removeAttribute(name) method.
the answer is e.
but i doubt that why "b" is wrong??
in api, it descrip that "Invalidates this session then unbinds any objects bound to it.".
so i think the answer b is also right.