What happens when I don’t enter any values for login credentials(username/password) and submit the form blankly.
When u don't enter any value in the TextBox and make a submit, what u get in the server is just an empty string not a null. Try with this code
String inputRequest = request.getParameter("name");
if (inputRequest.equals("")){
System.out.println(“Enter some value”);
}
It will work fine.
It can also be tried with JSTL Tags
c:if test="${param.name eq null}"
jsp:forward page="errorPage.jsp" /
/c:if
This will not forward your request to errorPage.jsp. You got to use
c:if test="${empty param.name}"
jsp:forward page="errorPage.jsp" /
/c:if
0 Comments:
Post a Comment
<< Home