User Authentication using JSP

Write a JSP to authenticate the user when he submits the login form using the user name and password from the database. If details are valid display welcome message otherwise display warning message.

login.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login Page</title>
</head>
<body>
<h1 align="center">Login Page</h1>
<form method="post" action="AuthUser.jsp">
<table>
<tr>
<td>E-Mail ID</td>
<td><input type="email" name="email" placeholder="E-Mail ID" required /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="upwd" placeholder="Password" required /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Sign-In"></td>
</tr>
</table>
</form>
</body>
</html>

AuthUser.jsp
<%@page import="java.sql.*" contentType="text/html" language="java" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Registered Users</title>
</head>
<body>
<%
String userId = request.getParameter("email");
String userPwd = request.getParameter("upwd");
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/onlinebookstore","root","admin");
Statement stmt=con.createStatement();
String q = "select loginid, email, loginpwd from reg;";
ResultSet rs = stmt.executeQuery(q);
int flag = 0;
while(rs.next()){
  if(userId.equals(rs.getString("email")) && userPwd.equals(rs.getString("loginpwd"))){
    flag=1;
    break;
  }
}
if(flag==1){
  out.print("Welcome <b>"+rs.getString("loginid")+"</b>");
}else{
  out.println("Invalid E-Mail ID or Password.");
}
stmt.close();
con.close();
%>
</table>
</body>
</html>