| Author |
Some issue with unBound. getting NullPointerException.
|
Yuva Kumar
Greenhorn
Joined: Jul 18, 2008
Posts: 12
|
|
Hi
I have a Servlet which implements HttpSessionBindingListener and has methods valueBound() and valueUnbound().
In my servlet, I have a function, which sets the servlet object to session upon which the valueBound function gets called internally.
But in valueBound(), I would like to call a function of an object which was already initialized in the init method itself. But I am getting NullPointerException (boObj is becoming null).
If instead of making a call to the function inside the object, I make the function available locally in the servlet, it is working fine.
Also, in that function, I am trying to insert a record in the table to store the logged in user id and session id. This is getting called only for the first user who logs in, but not for subsequent user login.
Could someone pl suggest as w.r.t the above issues, ie.
1) boObj is becoming null in valueBound()
2) After making function available locally, the function is called only once for the first user session and not for all user's sessions.
Thanks in advance for all your suggsions.
Regards,
Yuva
I have the code snippet as follows
n
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
I don't understand two things. Is your servlet (which implements GenericServlet or HttpServlet) also implementing HttpSessionBindingListener. If yes, then there will be two instances of your class, one will act as a servlet and one as session binding event listener. The init method will only be called on the servlet and not on the listener so the object boObj will be null.
Also I don't understand this statement
In my servlet, I have a function, which sets the servlet object to session upon which the valueBound function gets called internally.
Are you setting the servlet object into the session or just adding a normal object as attribute into the session...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
 |
|
|
subject: Some issue with unBound. getting NullPointerException.
|
|
|