aspose file tools*
The moose likes JSP and the fly likes java lang Null PointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "java lang Null PointerException" Watch "java lang Null PointerException" New topic
Author

java lang Null PointerException

bobby reddy
Greenhorn

Joined: Nov 05, 2007
Posts: 27
Hello everyone,
i have created a jsp. when i click save button, the data is being stored in the corresponding tables at the back end.When i try to see the data and again click save button later, it displays me java lang Null Pointer Exception. i have written output statements also but could not track this exception. Could any one tell me how to avoid this exception?

Thanks,
bobby
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

Don't de-reference nulls.

Sorry if that seems flip, but there's really not much else to say with the scant information you've given. The stack trace should tell you the exact line where the NPE is occurring. From there you should be able to backtrack to find out why you have a null reference that you did not expect


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
I'm not sure what you mean by "you could not track this exception". Wrap the statement in a try/catch block and post the stack trace. (Of course, you shouldn't be using Java code in a JSP to begin with, but that's a different issue.) In addition to the stack trace, also post the code that's causing it. Otherwise we'll have no clue on how to advise you.


Ping & DNS - my free Android networking tools app
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Start by looking at your server's logs.

Often you will get the exact line number in the JSP where the NullPointerException was thrown. Depending on the server, you might, instead get the line number in the generated servlet code.

Once you find the line number, look in that line for a method being called on an object. If there is only one method call on that line, you've found the object that is null. From there it should be easy to find the bug.

If there is any part of this that you don't understand, ask for clarification.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java lang Null PointerException