tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johnny Kewl" <>
Subject Re: getAttribute(null)?
Date Thu, 12 Jun 2008 17:51:13 GMT

----- Original Message ----- 
From: "Leffingwell, Jonathan R CTR FRCSE, JAX 7.2.2" 
To: <>
Sent: Thursday, June 12, 2008 4:44 PM
Subject: getAttribute(null)?

I have the following code that worked in Tomcat 5.0, but doesn't work in
Tomcat 5.5.26:

String formName = mapping.getAttribute();   // mapping is a variable of
type ActionMapping. In this scenario, formName is null.

if (null != session.getAttribute(formName)) {

formName is null.  In Tomcat 5.0.x, no exception was thrown and
processing continued (as if passing a null argument to getAttribute
simply returned NULL).  In Tomcat 5.5.26, a ServletException is thrown
(with a NullPointerException).

I know how to code a work-around (and have done so), but is this
considered a bug in Tomcat?

This code
            HttpSession session = request.getSession(true);
            Object obj = session.getAttribute(null);

Raises this exception

 java.util.Hashtable.get(Unknown Source)
 org.apache.catalina.session.StandardSession.getAttribute( org.apache.catalina.session.StandardSessionFacade.getAttribute(
NewServlet.processRequest( NewServlet.doGet( javax.servlet.http.HttpServlet.service(
javax.servlet.http.HttpServlet.service( Hash Table is throwing it...I'm
too young to remember 5 ;)But you maybe right, its possible that the internals used to use
a Vector...and when Java introduced new collections, it changed.You may have spotted a little
regression issue, but probably something thathasnt caught too many people.

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message