tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: NullPointerException during HttpServletRequest.getSession
Date Tue, 30 Sep 2003 19:08:42 GMT


>The symptom is a NullPointerException when I call getSession() on an
>HttpServletRequest object.  The HttpServletRequest object had
>been saved as an attribute of the Session that it contained.

This seems prone to problems.  How can storing the request itself as a
session attribute be valid?  A session by definition may have many
requests in it -- so you override the value of the attribute when a new
request comes in?

In any case, you could easily end up in a circular case where the
session has the request, and the request has a session associated with
it in tomcat.

>I tried looking at the CoyoteRequestFacade code but the directory
>containing it in the public download site was empty!  That was the code
>that threw the actual exception so I'm sure it could give some insight.

It's here:

However, it's been modified since the last release so the line number
may not be accurate.  Anyways, it's likely the request object itself had
been nulled out, giving NPE in request.getSession(....).

>Here are the classes in question; again I've tried to only include the
>original code:

I don't particularly feel like reading through them, though maybe
someone else does.  Without looking at them in detail, I would ask: can
you accomplish your requirements without storing the request object as a
session attribute?  I.e. get what you need from it (param values etc.),
store those in the session instead?

Yoav Shapira

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

View raw message