How to redirect first jsp page to another jsp page
by using Login page
Name it Account→
Finish→
Now type this code on Login.jsp
Full source code Login.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>My Login Page</h1>
<%
String UN=request.getParameter("user");
String PW=request.getParameter("pass");
if(UN.equals("admin")&&PW.equals("123"))
{
response.sendRedirect("Account.jsp");
}
%>
</html>
Type this code in Accout.jsp
Full Source code for Accout.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Welcome to my Account</h1>
Login Success
</body>
</html>
Full Source code for index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>Hello World!</h1> <form action="Login.jsp" method="get"> <label>Username </label> <input type="text" name="user"> <label>Password</label> <input type="password" name="pass"> <input type="submit" name="Submit"> </form> </body> </body> </html>
Output→run file
0 Comments:
Post a Comment