• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Null pointer exception ?

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all!,
I am using a servlet which simply
checks whether the session is
new.. if it is new, then send it to another page using redirect()
this is the error which it is showing
*************
Document moved
This document has moved here.
Error: 500
Location: /netzone/addfrm
Internal Servlet Error:
java.lang.NullPointerException
at horse.addfrm.doGet(addfrm.java:36)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at ngasi.a.a.n.a(Unknown Source)
at ezj.b.e.run(Unknown Source)
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's hard to tell without seeing the code for your "addfrm" class. I know the problem occurs at line 36, though!
Could you post the doGet method, and any others it calls so we can have a look? Don't forget to put code examples iside UBB CODE tags (for details, see the "UBB Code is ON" link to the left when you create a message).
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason for nullPointerException may be due to calling a method on null session object.

You may be checking session.isNew() on a null session object.
Firt you check weather it in null or nor and then check weather it is new or old.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
to solve your problem
put the null pointer exception in throws clause.
 
reply
    Bookmark Topic Watch Topic
  • New Topic