
String user = request.getParameter("username");
in this "user" value is null or not how to validate? before going further action.

Hi Friend,
Either you can do the following :
1)login.jsp:
<%@page import="java.sql.*"%> <html> <form method="post" action="check.jsp"> <table> <tr><td>Username:</td><td><input type="text" name="user"></td></tr> <tr><td>Password:</td><td><input type="text" name="pass"></td></tr> <tr><td></td><td><input type="submit" value="Submit"></td></tr> </table> </form> </html>
2)check.jsp:
<%
String user=request.getParameter("user");
String pass=request.getParameter("pass");
if(user.equals("")&&pass.equals("")){
response.sendRedirect("login.jsp");
}
else{
}
%>
Or you can use JavaScript for validation like this:
<%@page import="java.sql.*"%>
<html>
<script>
function validate(){
var username=document.form.user.value;
var password=document.form.pass.value;
if(username==""){
alert('Enter Username!');
return false;
}
if(password==""){
alert('Enter Password!');
return false;
}
return true;
}
</script>
<form name="form" method="post" action="check.jsp" onsubmit="javascript:return validate();">
<table>
<tr><td>Username:</td><td><input type="text" name="user"></td></tr>
<tr><td>Password:</td><td><input type="text" name="pass"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

Hi Friend,
How to get the message in login.jsp like "username or password is wrorng"

Once validating in check.jsp, i want error message on login.jsp like 'username or password is not provided' if username or password is null.
How get above thing.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.