File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "nullpointerexception " Watch "nullpointerexception " New topic


Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
a next.jsp is redirected from the
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.

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

Joined: Jul 29, 2008
Posts: 3921

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

Joined: Aug 03, 2009
Posts: 29

as per the above answer
replace this

by this

SCJP - Here for Knowledge..
I agree. Here's the link:
subject: nullpointerexception
It's not a secret anymore!