aspose file tools*
The moose likes Beginning Java and the fly likes nullpointerexception 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 » Beginning Java
Bookmark "nullpointerexception " Watch "nullpointerexception " New topic
Author

nullpointerexception

Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
a next.jsp is redirected from the previous.page.
when the previous page link to next.jsp together with query string
so that in the next.jsp can get the string by "request.getParameter('querystring')"
but when i re-submit form in next.

it always error : nullpointerexception , i thing is pointing out the "request.getParameter('querystring')"


i try to prevent null value in java code as belows:


it doesn't work.
how can i prevent this happen?

[Devaka: Added code tags - please UseCodeTags]
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
Check to see if your request refrence is null. It sounds like you are trying to call a method on a null object, which is giving you a null pointer exception.


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
how to prevent null object
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3168
    
  47

Parameter('querystring').equals(null) doesn't make any sense. Use == operator when you compare something with null.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Dhan Kumar
Greenhorn

Joined: Aug 03, 2009
Posts: 29

as per the above answer
replace this

by this


Dhan
SCJP - Here for Knowledge..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: nullpointerexception