Win a copy of Murach's Python Programming this week in the Jython/Python forum!
    Bookmark Topic Watch Topic
  • New Topic

Null pointer exception sometimes  RSS feed

 
ankur tyagi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Report post to moderator
hey i am writing a class file which takes values from database and adds them to arraylist and then a servlet uses those arraylist
to generate a web page..
the problem is that the servlet returns NULL POINTER EXCEPTION sometimes and sometimes the values are returned and are shown on the page.
usually this happens when i start the database and tomcat everything works fine but after refreshing the page 4-5 times or loading similar pages ..it starts to return NULL POINTER EXCEPTION ....i think this might be because of the fact that i am not closing the connections in the class file..
i am showing the code, can anyone suggest how to close connections according to this code.
Servlet

class file


thanks in advance
 
manoj r patil
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Report post to moderator
Can you also post the stack trace of the NullPointerException containing line number?
 
ankur tyagi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Report post to moderator
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
AirportDD.getFlights(AirportDD.java:34)
AirportSelectDD.doPost(AirportSelectDD.java:18)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.28 logs.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Ankur Tyagi,

It looks like a lot of people have already spent time trying to help you with this issue in another thread.
http://www.coderanch.com/t/493572/Servlets/java/Null-Pointer-Exception

By starting a new one, you've not only wasted the time of the people who've tried to help you, your wasting the time of the people who might try to help you here because they won't know what ideas have already been suggested.

If you still haven't solved this, post what you've changed to the original.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!