900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > JSP实现简单的登录页面实现及代码(非连接数据库)

JSP实现简单的登录页面实现及代码(非连接数据库)

时间:2023-04-20 02:34:20

相关推荐

JSP实现简单的登录页面实现及代码(非连接数据库)

**

JSP实现简单的登录页面实现及代码(非连接数据库)

**

1、实现一个简单的登陆页面;

2、如果登陆成功,提示页面欢迎你,进入我的主页;

3、如果登陆不成功跳转到登陆页面;

4、使用固定用户名和密码即可。

jsp文件目录

总共分为五块内容

1. login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>欢迎登陆!</title></head><body><%--登录页面 --%><h1 style="text-align:center;">欢迎登录!</h1><form action="loginProcess.jsp"><table align="center" border="10"><tr><td>用户名:</td><td><input type="text" name="user"></td></tr><tr><td>密 码:</td><td><input type="password" name="password"></td></tr><tr><td>确认密码:</td><td><input type="password" name="password2"></td></tr><tr><td><input type="submit" name="提交"></td><td><input type="reset" name="重置"></td></tr></table></form></body></html>

2. loginProcess.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>登录处理</title></head><body><%--登录处理 --%><%request.setCharacterEncoding("UTF-8");String name=request.getParameter("user");String password=request.getParameter("password"); String password2=request.getParameter("password");%><% if("kongjunjie".equals(name) && "1701110273".equals(password) && (password==password2) ){%><jsp:forward page="success.jsp"></jsp:forward><%}else{%><jsp:forward page="error.jsp"></jsp:forward><%}%></body></html>

3. success.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>登录成功,跳转到主页</title></head><body><%--登录成功,进入我的主页 --%><h1><%=request.getParameter("user")%>恭喜你登录成功!!!</h1><br><h1><a href="homepage.jsp">点击进入我的主页</a></h1></body></html>

4.homepage.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>我的主页</title></head><body><%--我的主页 --%><h1>这里是我的主页,欢迎你!!!</h1></body></html>

5. error.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>登录错误</title></head><body><%--登录出错 --%><h1>登录信息输入错误,请重新输入!</h1><br><h1><a href="login.jsp">点击进入登录页面</a></h1></body></html>

运行结果:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。