Bug 22587 - sess:attributes tag shows removed attribute
Summary: sess:attributes tag shows removed attribute
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Session Taglib (show other bugs)
Version: 1.1
Hardware: Other other
: P3 normal with 1 vote (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2003-08-20 12:52 UTC by Jozef Chocholacek
Modified: 2005-09-24 08:56 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Jozef Chocholacek 2003-08-20 12:52:32 UTC
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">
<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")) {
  } else if (action.equals("remove")) {
<%= action %>
<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>
  <sess:attributes id="attr">
    Name: '<jsp:getProperty name="attr" property="name"/>',
    Value: '<jsp:getProperty name="attr" property="value"/>'
  Enumeration atts = session.getAttributeNames();
  while (atts.hasMoreElements()) {
     String name = (String) atts.nextElement();
  '<%= name %>' = '<%= session.getAttribute(name) %>'<br/>
Comment 1 Martin Cooper 2003-12-09 07:30:58 UTC
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.
Comment 2 Rahul Akolkar 2005-09-24 16:56:59 UTC
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.