This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
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
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3013

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

Founder of ExamLab and Systemup
See how I can help you to become an awesome programmer
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
Similar Threads
NullPointerException and request.getParameter()
question about request.getParameter().
pass parameter from jsp to jsp
HTML and Servlets
Displaytag : Not getting to the same page after modifying record