Discussions

Web tier: servlets, JSP, Web frameworks: JSTL way for doing session.removeAttribute( "key" )

  1. Hi,

    Is there a JSTL way of removing objects in session, something like <%= session.removeAttribute("key") %>? I tried doing something like <c:remove var="${sessionScope['key']}"/> but that did not work. Any ideas would be appreciated.

    -los
  2. For an object keyed into the session as "cart" you would remove it by using

    <c:remove var="cart" scope="session"/>

    Hope this helps.
  3. The <c:remove> tag does not work. seems like this tag only works if you have previously used the <c:set var="..." />, i.e. the variable var has to be scoped to the page (or so it seems like).

    -los