java门禁登录界面代码 jdk门禁怎么修改开门密码

用java做好的登陆界面,当登陆成功后跳转到下个页面的代码是什么?用java做好的登陆界面,当登陆成功后跳转到下个页面的代码如下:
如果登陆验证是在jsp中,那么跳转可以写成
1.response.sendRedirct("跳转到页面");
2.jsp:forward page="跳转页面"/
3.response.setHeader("Location","");
如果是登陆验证是在servlet中,那么中转可以写成
1.response.sendRedirect("/a.jsp");
2.RequestDispatcher dispatcher = request.getRequestDispatcher("/a.jsp");
dispatcher .forward(request, response);
也可以使用js代码实现:
script
function validate(){
window.location.href="https://www.04ip.com/index.jsp";
}
/script
jsp登陆界面源代码1、login.jsp文件
%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%
%@ page import="java.util.*" %
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
html
head
title登录页面/title
/head
body
form name="loginForm" method="post" action="judgeUser.jsp"
table
tr
td用户名:input type="text" name="userName" id="userName"/td
/tr
tr
td密码:input type="password" name="password" id="password"/td
/tr
tr
tdinput type="submit" value="https://www.04ip.com/post/登录" style="background-color:pink" input
type="reset" value="https://www.04ip.com/post/重置" style="background-color:red"/td
/tr
/table
/form
/body
/html
2、judge.jsp文件
%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%
%@ page import="java.util.*" %
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
html
head
title身份验证/title
/head
body
%
request.setCharacterEncoding("GB18030");
String name = request.getParameter("userName");
String password = request.getParameter("password");
if(name.equals("abc") password.equals("123")) {
3、afterLogin.jsp文件
%
jsp:forward page="afterLogin.jsp"
jsp:param name="userName" value="https://www.04ip.com/post/%=name%"/
/jsp:forward
%
}
else {
%
jsp:forward page="login.jsp"/
%
}
%
/body
/html
%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
html
head
title登录成功/title
/head
body
%
request.setCharacterEncoding("GB18030");
String name = request.getParameter("userName");
out.println("欢迎你:" + name);
%
/body
/html
扩展资料:
java web登录界面源代码:
1、Data_uil.java文件
import java.sql.*;
public class Data_uil
{
publicConnection getConnection()
{
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}catch(ClassNotFoundException e)
{
e.printStackTrace();
}
String user="***";
String password="***";
String url="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=***";
Connection con=null;
try{
con=DriverManager.getConnection(url,user,password);
}catch(SQLException e)
{
e.printStackTrace();
}
return con;
}
publicString selectPassword(String username)
{
Connection connection=getConnection();
String sql="select *from login where username=?";
PreparedStatement preparedStatement=null;
ResultSet result=null;
String password=null;
try{
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,username);
result=preparedStatement.executeQuery();//可执行的查询

推荐阅读