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
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: 3013
    
  35

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
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
 
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