Add some attributes to the session, then remove them all, and the attributes tag will still show the last attribute as present in the session (but it is not really there - see the code): <%@ page language="java" contentType="text/html" pageEncoding="UTF-8" %> <%@ page import="java.util.*" %> <%@ taglib uri="http://jakarta.apache.org/taglibs/session-1.0" prefix="sess" %> <!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <title>Pokus</title> </head> <body bgcolor="#FFFFFF"> <% String id = request.getParameter("id"); String value = request.getParameter("value"); String action = request.getParameter("action"); if (action==null) action="no action"; if (action.equals("add")) { session.setAttribute(id,value); } else if (action.equals("remove")) { session.removeAttribute(id); } %> <%= action %> <hr/> <ul> <li><a href="pokus.jsp?action=add&id=1&value=bla">1/bla</a></li> <li><a href="pokus.jsp?action=add&id=1&value=huh">1/huh</a></li> <li><a href="pokus.jsp?action=add&id=2&value=foo">2/foo</a></li> <li><a href="pokus.jsp?action=add&id=2&value=bar">2/bar</a></li> <li><a href="pokus.jsp?action=remove&id=1">remove 1</a></li> <li><a href="pokus.jsp?action=remove&id=2">remove 2</a></li> </ul> <hr/> <sess:attributes id="attr"> Name: '<jsp:getProperty name="attr" property="name"/>', Value: '<jsp:getProperty name="attr" property="value"/>' <br/> </sess:attributes> <hr/> <% Enumeration atts = session.getAttributeNames(); while (atts.hasMoreElements()) { String name = (String) atts.nextElement(); %> '<%= name %>' = '<%= session.getAttribute(name) %>'<br/> <% } %> <hr/> </body> </html>
I suspect this has to do with attribute synchronisation points between the tags and the page. IMHO, the tag is accessing session attributes in a way that does not guarantee synchronisation.
The session taglib has been deprecated, we do not expect any development around it in the near future. Please switch to the using JSTL, if possible.