Strange servlet exception

C

CarloC

Hi,
inside my generic servlet I get this error when I call this method:
'session.getAttribute' command (line 36):

java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:336)
at
org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:
1024)
at
org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessionFacade.java:
110)
at workcity.servlet.GenericServlet.checkToken(GenericServlet.java:36)

This is the java code:

HttpSession session = req.getSession();
ArcUtente vo = (ArcUtente) session.getAttribute(token);

req is a HttpServletRequest object !=null and
token is a String object != null.

You can help my?
Carlo
 
D

Daniel Pitts

Hi,
inside my generic servlet I get this error when I call this method:
'session.getAttribute' command (line 36):

java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:336)
at
org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:
1024)
at
org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessionFacade.java:
110)
at workcity.servlet.GenericServlet.checkToken(GenericServlet.java:36)

This is the java code:

HttpSession session = req.getSession();
ArcUtente vo = (ArcUtente) session.getAttribute(token);

req is a HttpServletRequest object !=null and
token is a String object != null.

You can help my?
Carlo

Looking at the JavaDoc for Hastable:
* @throws NullPointerException if the specified key is null
It very well could be token really is null.
Just to verify, try this:

HttpSession session = req.getSession();
if (token == null) { throw new NullPointerException("Token really IS
null!") };
ArcUtente vo = (ArcUtente) session.getAttribute(token);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,274
Latest member
JessMcMast

Latest Threads

Top