File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Please solve my "java.lang.NullPointerException" error" Watch "Please solve my "java.lang.NullPointerException" error" New topic
Author

Please solve my "java.lang.NullPointerException" error

Viruthagiri Thirumalvalavan
Greenhorn

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
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

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
Author
Rancher

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.
 
 
subject: Please solve my "java.lang.NullPointerException" error