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 sometimes

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
https://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.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic