• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please solve my "java.lang.NullPointerException" error

 
Viruthagiri Thirumalvalavan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My project is e learning project. I've a "choose the correct answer" module. When the click the "begin test" button it should fetch the questions and options from database and display it. Instead of that my page displays "java.lang.NullPointerException".
I've assigned unique values for each error. So the exact error it display as

"error occured 56 : java.lang.NullPointerException"

I have found the area of the error. but i couldn't solve it.
My codings are as follows



Please help me to solve this error. i'll be very thankful to you. If you need extra code tell me which part you want to solve this error. I'll post here. thanks to everyone. A little piece of help also appriciated
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step 1: Move the Java code out of the JSP and into a Java class where it belongs. Not only is this a best practice (while putting Java code into a JSP is most definitely not), it will make the code easier to debug.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The line number in the stack is pointing to a line of Java code in the generated Servlet source file, not the JSP.

Depending on which container you're using the actual source file (if saved) will be in different places.
Much easier to solve if your Java code is somewhere other than your JSP.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most likely objRsQ is null, since that's the only Java operation happening in the try/catch block for error "56"--is there a compelling reason to use completely arbitrary numbers, of all things, to indicate where an error occurred?! How about something like: "Error while trying to display info from the result set" or something that's actually relevant and useful? Just an idea.

In any case, it's almost impossible to make sense of what you're doing: besides all the Java code in a JSP (booooo! :) the random indentation makes understanding any sort of structure much more difficult than necessary.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic