File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes java.lang.NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "java.lang.NullPointerException" Watch "java.lang.NullPointerException" New topic
Author

java.lang.NullPointerException

Samer, qc
Greenhorn

Joined: Jan 16, 2001
Posts: 2
Hello,
Can anyone tell me why i'm getting this error:
java.lang.NullPointerException
here is the code:

Samer
Sowmya Vinay
Greenhorn

Joined: Feb 01, 2001
Posts: 24
From what I see in the code snippet, I find that you are accessing a form parameter from request, but you are not making sure that it exists i.e it ia non-null value. Make sure that it is not returning a null value by including this statement "if (barCodeValue!=null)" as soon as you populate the barcodeValue variable from the request and before using it anywhere else.
The rule of thumb for dealing with Null Pointer Exceptions is to make sure that you always check whether the object populated by accessing any method is null, before invoking any of its methods.
Hope this helps.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"Samer, qc",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NullPointerException