Hi,

I have problem with Tomcat 6.0 StandardSession implementation.
We have an application who calls setAttribute("myAttr", myValue), and try to 
get this attribute in a method launched in valueBound(), but only gets null value.

According to source code, the setAttribute() method calls valueBound *before* 
setting attribute in attributes Map :

public void setAttribute(String name, Object value, boolean notify)
{
[...]
        // Call the valueBound() method if necessary
        if (notify && value instanceof HttpSessionBindingListener)
        {
            // Don't call any notification if replacing with the same value
            Object oldValue = attributes.get(name);
            if (value != oldValue)
            {
                event = new HttpSessionBindingEvent(getSession(), name, value);
                try
                {
                    ((HttpSessionBindingListener) value).valueBound(event);
                }
                catch (Throwable t)
                {
                    
manager.getContainer().getLogger().error(sm.getString("standardSession.bindingEvent"),
 t);
                }
            }
        }

        // Replace or add this attribute
        Object unbound = attributes.put(name, value);

        // Call the valueUnbound() method if necessary
     [...]
}

Why valueBound() is called before setting the attribute in the map ? Is it 
allowed to call getAttribute() from valueBound() ? Is the following code 
correct ?

setAttribute("myAttr", myValue);
-> valueBound() event fired

In the valueBound() :
// getAttribute() always returns null
Object myAttr = getAttribute("myAttr");

Thanks in advance.

Regards,
Thomas


Ce message est protégé par les règles relatives au secret des correspondances. 
Il est donc établi à destination exclusive de son destinataire. Celui-ci peut 
donc contenir des informations confidentielles. La divulgation de ces 
informations est à ce titre rigoureusement interdite. Si vous avez reçu ce 
message par erreur, merci de le renvoyer à l'expéditeur dont l'adresse e-mail 
figure ci-dessus et de détruire le message ainsi que toute pièce jointe.

This message is protected by the secrecy of correspondence rules. Therefore, 
this message is intended solely for the attention of the addressee. This 
message may contain privileged or confidential information, as such the 
disclosure of these informations is strictly forbidden. If, by mistake, you 
have received this message, please return this message to the addressser whose 
e-mail address is written above and destroy this message and all files attached.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to