wood burning stoves 2.0
The moose likes JSP and the fly likes Please solve my Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Please solve my "java.lang.NullPointerException" error" Watch "Please solve my "java.lang.NullPointerException" error" New topic

Please solve my "java.lang.NullPointerException" error

Viruthagiri Thirumalvalavan

Joined: Mar 21, 2010
Posts: 3
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

Joined: Jan 10, 2002
Posts: 63838

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.

[Asking smart questions] [About Bear] [Books by Bear]
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

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.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
David Newton

Joined: Sep 29, 2008
Posts: 12617

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.
I agree. Here's the link: http://aspose.com/file-tools
subject: Please solve my "java.lang.NullPointerException" error
It's not a secret anymore!