求jsp简单的登陆跳转注册页面

来源:百度知道 编辑:UC知道 时间:2024/06/07 11:30:10
新手求一简单一点能看懂就行不用连接数据库,首先一个登陆页面然后跳转到注册里面 登陆成功要显示登陆成功 ,失败显示“密码或者用户名错了”
跳转到注册里面 注册成功显示注册成功, 密码限制

1) redirect 方式
response.sendRedirect("/a.jsp");
页面的路径是相对路径。sendRedirect可以将页面跳转到任何页面,不一定局限于本web应用中,如:
response.sendRedirect("URL");
跳转后浏览器地址栏变化。
这种方式要传值出去的话,只能在url中带parameter或者放在session中,无法使用request.setAttribute来传递。
2) forward方式
RequestDispatcher dispatcher = request.getRequestDispatcher("/a.jsp");
dispatcher .forward(request, response);
Servlet页面跳转的路径是相对路径。forward方式只能跳转到本web应用中的页面上。
跳转后浏览器地址栏不会变化。
使用这种方式跳转,传值可以使用三种方法:url中带parameter,session,request.setAttribute

登陆页:
<%@ page language="java" pageEncoding="GB18030"%>
<head>
</head>
<body>
<form action="login_success.jsp" method="post">
用户名:
<input type="text" name="username" />
<br>
密 码
<input type="password" name="password" />
<br>
<inpu