I have a new user sign up form that sends info to a
servlet which intern checks for dupe usernames, emails etc. It works fine but constantly throws a null pointer exception, NOT a fatal one...the servlet still runs but my logs are full of these exceptions. Im 99.9% sure its from non-javascript enabled browsers so I built a catch for any of the info that would come in as null telling them they have to go back & do the from again....What I DONT understand is why the null pointers are happening & Im getting real sick of seeing them.....HOw does checking for a null value intern throw a null pointer??? Ive included the form code & the section of the servlet that throws the exception (And commented it as such) Any help here would do wonders for my sanity!! Thanks
///Sign Up form code
<FORM METHOD=POST action="/servlet/NewUserSignUp" onSubmit="return newUserVal();">
<input type="text" name="userName" size="15" maxLength="10"> Please Select A Username.
(Letters, Numbers & underscores (_) or dashes (-) ONLY)
<br> <br>
<input type="text" name="emailAddy" size="15"> Please enter a valid email address
(your password will be emailed to this address).
<br> <br>
<select name="gender" size="1">
<option value="" Selected>Select
<option value="1"> Male
<option value="2"> Female
<option value="3"> Couple
</select> Please select your gender/martial status.
<br> <br>
<input type="submit" value="Sign Me Up">
</FORM>
//Exception throwing section of servlet (Throws at if != null)
try{
if (((req.getParameter("userName") != null) | | (!req.getParameter("userName").trim().equals(""))) | | ((req.getParameter("emailAddy") != null) | | (!req.getParameter("emailAddy").trim().equals(""))) | | (((req.getParameter("gender") != null)) | | (!req.getParameter("gender").trim().equals("")))) {
String userName = null;
String emailAddy = null;
int genderStat;
String passWord = null;
String custIPAddress = req.getRemoteAddr();
String custHost = req.getRemoteHost();
userName = req.getParameter("userName").toUpperCase().trim();
emailAddy = req.getParameter("emailAddy").toUpperCase().trim();
genderStat = Integer.parseInt(req.getParameter("gender"));
res.setContentType ("text/html");
out = res.getWriter();
ONce again thanks for the look see, maybe there is something stupid Im missing here & Ive just plain stared at it too much!