您的位置:

jsphtml登录源码的简单介绍

jsphtml登录源码的简单介绍

更新:

本文目录一览:

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="登录" style="background-color:pink" input

type="reset" value="重置" 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="%=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

{

public  Connection 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;

}

public  String 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();//可执行的     查询

if(result.next())

password=result.getString("password");

}catch(SQLException e){

e.printStackTrace();

}finally

{

close(preparedStatement);

close(result);

close(connection);

}

System.out.println("找到的数据库密码为:"+password);

return password; 

}

public  void close (Connection con)

{

try{

if(con!=null)

{

con.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public  void close (PreparedStatement preparedStatement)

{

try{

if(preparedStatement!=null)

{

preparedStatement.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public  void close(ResultSet resultSet)

{

try{

if(resultSet!=null)

{

resultSet.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

}

2、login_check.jsp:文件

%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%

!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""

html

head

meta http-equiv="Content-Type" content="text/html; charset=utf-8"

title验证用户密码/title

/head

body

jsp:useBean id="util" class="util.Data_uil" scope="page" /

%

String username=(String)request.getParameter("username");

String password=(String)request.getParameter("password");

if(username==null||"".equals(username))

{

out.print("script language='javaScript' alert('用户名不能为空');/script");

response.setHeader("refresh", "0;url=user_login.jsp");

}

else

{

System.out.println("输入的用户名:"+username);

String passwordInDataBase=util.selectPassword(username);

System.out.println("密码:"+passwordInDataBase);

if(passwordInDataBase==null||"".equals(passwordInDataBase))

{

out.print("script language='javaScript' alert('用户名不存在');/script");

response.setHeader("refresh", "0;url=user_login.jsp");

}

else if(passwordInDataBase.equals(password))

{

out.print("script language='javaScript' alert('登录成功');/script");

response.setHeader("refresh", "0;url=loginSucces.jsp");

}

else

{

out.print("script language='javaScript' alert('密码错误');/script");

response.setHeader("refresh", "0;url=user_login.jsp");

}

}

%

/body

/html

3、loginSucces.jsp文件

%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%

!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""

html

head

meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"

titleInsert title here/title

/head

body

hr size="10" width="26%" align="left" color="green"

font size="6" color="red" 登录成功 /font

hr size="10" width="26%" align="left" color="green"

/body

/html

4、user_login.jsp文件

%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%

!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""

html

head

meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"

title登录界面/title

/head

body  background="C:\Users\win8\workspace\Login\image\9dcbdc339e72a5663b5c289fb5573c13_10.jpg"

center

brbrbrbrbrbr

h1 style="color:yellow"Login/h1

br

form name="loginForm" action="login_check.jsp" method="post" 

table Border="0"

tr

td账号/td

tdinput type="text" name="username"/td

/tr

tr

td密码/td

tdinput type="password" name="password"

/td

/tr

/table

br

input type="submit" value="登录" style="color:#BC8F8F"

/form

/center

/body

/html

jsp登录代码

login.jsp

%@ page language="java" pageEncoding="utf-8"%

html

head

title登录/title

script language="javascript"

function checkform() {

if (form4.name.value.length==0){

alert("请输入正确的姓名!");

form4.name.focus();

return false;

}

if (form4.password.value.length==0){

alert("请输入正确的密码!");

form4.password.focus();

return false;

}

}

/script

style type="text/css"

!--

#Layer1 {

position:absolute;

left:16px;

top:442px;

width:276px;

height:239px;

z-index:1;

}

#Layer2 {

position:absolute;

left:29px;

top:305px;

width:181px;

height:137px;

z-index:2;

}

--

/style

/head

body

div id="Layer1" style="left: 16px; width: 369px;"

form id="form4" name="form4" method="post" action="loginControl.jsp"

table border="0" style="top: 443px; left: 17px; width: 240px; height: 240px;"

tr

td colspan="3" div align="center"strong用户登录/strong/div/td

/tr

tr

td div align="right"strong用户名:/strong/div/td

td colspan="1"input type="text" name="name" //td

/tr

tr

td div align="right"strong密 码:/strongstrong /strong/div/td

td colspan="1"input type="password" name="password" //td

/tr

tr

td height="37" colspan="3"

label

    input type="submit" name="Submit" value="登录"onclick="javascript:return(checkform());" /

  

/label

input type="reset" name="reset" value="重填" /

/td

/tr

/table

/form

/div

div id="Layer2" img src=2.jpg width="120" height="120"//div

label/label

/body

/html

loginControl.jsp

%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%

%@ include file="tdb.jsp"%

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

style type="text/css"

!--

#Layer1 {

position:absolute;

left:9px;

top:363px;

width:218px;

height:133px;

z-index:1;

}

--

/style

head

titleMy JSP 'loginControl.jsp' starting page/title

/head

body

%

String name= request.getParameter("name");

String password= request.getParameter("password");

System.out.println("成功11111");

sql="SELECT * FROM tdb WHERE user_Name='"+name+"' AND user_Pwd='"+password+"'";

rs = smt.executeQuery(sql);

if(!rs.next())

{%

script type="text/javascript"

alert("用户名和密码不正确!!!");

window.location.href='index.jsp';

/script%

}

response.sendRedirect("main.jsp");

%

/body

/html

tdb.jsp

%

Class.forName("oracle.jdbc.OracleDriver");

java.sql.Connection con=null;

con=java.sql.DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ABC","zhan","123");

java.sql.Statement smt=con.createStatement();

java.sql.ResultSet rs;

java.sql.PreparedStatement ps;

String sql;

%

编写用户注册于登录的JSP页面的全部程序代码

3个jsp文件,第一个是login.jsp,第二个是judge.jsp,第三个是afterLogin.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="登录" style="background-color:pink" input type="reset" value="重置" style="background-color:red"/td

/tr

/table

/form

/body

/html

%@ 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")) {

%

jsp:forward page="afterLogin.jsp"

jsp:param name="userName" value="%=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

jsphtml登录源码的简单介绍

本文目录一览: 1、jsp登陆界面源代码 2、jsp登录代码 3、编写用户注册于登录的JSP页面的全部程序代码 jsp登陆界面源代码 1、login.jsp文件%@ page language="ja

2023-12-08
python使用笔记23的简单介绍

2022-11-10
jsp源码修改title的简单介绍

本文目录一览: 1、当修改JSP的源代码时,通过重新加载此JSP,通常可以在浏览器中看到这种修改。对于由JSP转化而来的SERVLET 2、jsp登陆界面源代码 3、jsp 中网站的首页源代码 4、网

2023-12-08
javascript入门笔记1的简单介绍

2022-11-18
印象笔记记录java学习(Java成长笔记)

2022-11-12
jsp实现登陆界面代码(jsp简单登录界面代码)

本文目录一览: 1、jsp 登陆界面的代码 2、编写用户注册于登录的JSP页面的全部程序代码 3、求JSP登陆界面代码 4、jsp登陆界面源代码 5、jsp实现简单的登录界面 jsp 登陆界面的代码

2023-12-08
jsp做的网络系统源代码谁有的简单介绍

本文目录一览: 1、急求一个用jsp做的网上购物系统的源代码! 2、jsp做的网络系统源代码谁有? 3、jsp登陆界面源代码 4、急求一个用JSP做的网上商城系统设计与实现——后台管理子系统的源代码!

2023-12-08
java包笔记,Java语言包

2022-11-18
java客户端学习笔记(java开发笔记)

2022-11-14
htmljs编程笔记(html代码笔记)

本文目录一览: 1、html代码和JS代码有什么区别 2、如何在html中调用js函数 3、JavaScript学习笔记之数组基本操作示例 4、HTML5初学者笔记 5、《web前端笔记7》js字符—

2023-12-08
php用户登录源代码,php用户管理源码

2023-01-08
网上订餐系统jsp源代码的简单介绍

本文目录一览: 1、求一份计算机本科的毕业设计,题目只要计算机类的就可以 2、有哪些适合新手练手的Java项目 3、兄弟,你能发一下jsp点餐系统吗,2691449978@qq.com? 4、jsp登

2023-12-08
javascript简要笔记,JavaScript读书笔记

2022-11-17
c到c语言笔记的简单介绍

2022-11-24
单点登录java,单点登录java实现sso单点登录

2023-01-07
linuxmysql源码包的简单介绍

2022-11-18
java基础知识学习笔记一,Java基础笔记

2022-11-21
java笔记,大学java笔记

2022-11-28
java基础第一天学习笔记(java课程笔记)

2022-11-09
java学习笔记(java初学笔记)

2022-11-14