学生登陆查询系统
1 程序的主要功能及特点
实现一个登录界面的基本功能,具体要求:
- 登录界面login.jsp含有表单,用户能够输入用户名和密码,并提交表单给verify.jsp。
- Verify.jsp读取表单信息,并验证接收的用户名和密码是否与verify.jsp内置的相应变量值一致。
- 如果一致,则转向页面success.jsp,显示"成功登录"并可以手动选择要查询的系统。
- 如果不一致,则转向页面failure.jsp,显示"登录失败"并手动返回。
-
本系统默认:用户名14347119密码wuxing为正确。
2 程序部署及运行截图和相应说明(手工部署)
部署
- 成功登陆后可以选择登陆某一查询系统,见下图
- 不成功登陆提示错误并返回,见下图
SUCCESS LOGIN
FAILURE LOGIN
3 程序源代码
login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>loginPage</title>
</head>
<body bgcolor=AliceBlue >
<form name="loginForm" method="post" action="verify.jsp">
<center>
<font size=6>学生微教务</font>
</center>
<center>
<table>
<tr>
<td height="40" weight="100">UserName<input type="text" name="userName" id="userName"></td>
</tr>
<tr>
<td height="40" weight="100">Password<input type="password" name="password" id="password"></td>
</tr>
<tr>
<td><input type="submit" value="login" style="background-color:white"> <input type="reset" value="reset" style="background-color:yellow"></td>
</tr>
</table>
</center>
</form>
</body>
</html>verify.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Authentication</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String name = request.getParameter("userName");
String password = request.getParameter("password");
if(name.equals("14347119")&& password.equals("wuxing")) {
%>
<jsp:forward page="success.jsp">
<jsp:param name="userName" value="<%=name%>"/></jsp:forward>
<%}
else{
%>
<jsp:forward page="failure.jsp"></jsp:forward>
<%}
%>
</body>
</html>success.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Login Success</title>
</head>
<body bgcolor=AliceBlue>
<form name="SUCCESS" method="post" action="JMP.jsp">
<center>
<%request.setCharacterEncoding("UTF-8");
String name = request.getParameter("userName");
out.println("Welcome:"+name);%><BR>
</center>
<center>
<BR><font size="6">Score Query System</font><BR>
<BR><font size="4">Please select one item to check</font>
<Select name="grade" >
<Option selected value="http://wjw.sysu.edu.cn">Academic performance</option>
<Option value="http://cet.99sushe.com">CET-4 & CET-6</option>
<Option value="http://chaxun.neea.edu.cn/examcenter/query.cn?op=doQueryCond&pram=results&sid=300"> NCRE</option>
</Select>
<BR><BR> <Input type="submit" value="submit" name="submit">
</center>
</body>
</html>failure.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login Failure</title>
</head>
<body bgcolor="Aliceblue">
<center><font size="4">
Incorrect username or password! Please return and try again.
<BR><A href="login.jsp" >return
</font>
</center>
</body>
</html>JMP.JSP(用于跳转网站页面)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JMP</title>
</head>
<body>
<% String s=request.getParameter("grade");
response.sendRedirect( s); %>
</body>
</html>