Title:
I would consider trying this:

if ((req.getParamValue[0].length() != 0) (b.equals("yes") == true)))

It would seem that b is generating a NullPointerException for params not checked. Checking first to see that theparam has a value (by checking the length of the first--and probably only--value) might do the trick. Using the shortcircuited will allow the code to fall through if null, and not generate the NPException.

Hope this helps.


----- Original Message -----
From: Brad Whiting
To: [EMAIL PROTECTED]
Sent: Monday, September 24, 2001 11:39 PM
Subject: Null pointer exception
Hello all,

I am a rookie java servlet programmer, and I am getting an error that is confusing me.

I have created an HTML form that has a large number of check boxes. The idea being that each checkbox represents a column in a database. I hope to structure an sql call that will include only the checked columns. The odd thing about the program is that it works fine if I check every box. If I leave any unchecked I get a null pointer exception at the point in the code where I am checking to see if the box is checked.

This is an example of my html input statement:

input type=checkbox name=cpumod value="yes" CPU Model

This is an example of my servlet code that checks:

String b = req.getParameter("cpumod");
if (b.equals("yes") == true)
sqlcom2 += ",\n CPUMOD";

This is the exception I see in my logs:

Instantiate: DBgetsysid&nb

This message was posted using eunum
To interact with a real-time, threaded interface to this e-mail list, clickthe link below:

[EMAIL PROTECTED]

___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to