In "Input.jsp" page, we have a form including a text box field for user to enter their name, like <INPUT TYPE="text" NAME="userName" ...>, when user clicks the submit button, it goes to "ProcessServlet.java". Now in the receiving
servlet, if we use
String name = req.getParameter("userName");
it should get the input string, but we also need to handle a case when user does NOT enter anything in the box, we want to redirect to an error page. but, I found the code
if(name == null)
res.sendRedirect("errorPage.htm");
does NOT work though.
Is it because the "req.getParameter("userName")" is NOT returning a null string even user doesn't enter anything ? then what's the easiest way to detect if user enters anything using the .getParameter() ?
Thanks,
Ian