登录的源码(1)登录(2)处理登录(3)登录成功(4)登录失败 哪里错了求解?????
(1)
<%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<form action="dologin.jsp" method="post">
<table>
<tr><td>用户名</td></tr>
<tr><td><input type="text" name="username"></td></tr>
<tr><td>密码</td></tr>
<tr><td><input type="password" name="password"></td></tr>
<tr><td>
<input type="submit" name="submit" value="登录">
</td></tr>
</table>
</form>
</body>
</html>
(2)
<%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String username ="";
String password ="";
request.setCharacterEncoding("utf-8"); //防止出现中文乱码
username=request.getParameter("username");
password=request.getParameter("password");
//如果用户名和密码都等于admin则登陆成功
if("admin".equals(username)&&"admin".equals(password))
{
request.getRequestDispatcher("Login_success.jsp").forward(request, response);
}
else
{
response.sendRedirect("Login_failure.jsp");
}
%>
(3)
<%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
登录成功
</body>
</html>
(4)
<%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
登录失败 <a href="Login.jsp">重新登录</a>
</body>
</html>