谁给我一个jsp大型网站源代码(用jsp写一个网站)

本文目录一览:

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企业网站源码

你去找找《JSP数据库编程指南》这本书,书后附带的光盘好像有好几个例子

jsp 中网站的首页源代码

这是最简单的一个例子,数据库要你自己建,用的是ACCESS

%@ page contentType=”text/html; charset=gb2312″ language=”java” import=”java.sql.*” errorPage=”” %

html

head

meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″

titleJSP连接Access数据库/title

style type=”text/css”

!–

.style1 {

font-size: 20px;

font-weight: bold;

}

/style

/headbody

div align=”center” class=”style1″JSP连接Access数据库/div

br

hr

p%

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); //载入驱动程序类别

Connection con = DriverManager.getConnection(“jdbc:odbc:jspdata”); //建立数据库链接,jspdata为ODBC数据源名称

//建立Statement对象

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

ResultSet.CONCUR_READ_ONLY);

ResultSet rs = stmt.executeQuery(“select * from lyb”); //建立ResultSet(结果集)对象,并执行SQL语句

%

/p

p align=”center”NUMB1数据表中记录如下/p

table width=”640″ border=”1″ align=”center” bordercolor=”#7188e0″

tr bgcolor=”d1d1ff”

th width=”49″编号/th

th width=”90″姓名/th

th width=”126″E-mail/th

th width=”221″网站/th

th width=”80″QQ/th

/tr

%

while(rs.next())

{

%

tr bgcolor=”#f8f8f8″

th%= rs.getString(1) %/th

th%= rs.getString(2) %/th

th%= rs.getString(3) %/th

th bgcolor=”#f6f6f8″%= rs.getString(4) %/th

th%= rs.getString(5) %/th

/tr

%

}

rs.close();

stmt.close();

con.close();

%

/table

p align=”center”br

如果您能看到表格中的数据,说明连接数据库成功!/p

/body

/html

原创文章,作者:小蓝,如若转载,请注明出处:https://www.506064.com/n/230645.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
小蓝小蓝
上一篇 2024-12-10 18:18
下一篇 2024-12-10 18:18

相关推荐

  • Python爬虫可以爬哪些网站

    Python是被广泛运用于数据处理和分析领域的编程语言之一。它具有易用性、灵活性和成本效益高等特点,因此越来越多的人开始使用它进行网站爬取。本文将从多个方面详细阐述,Python爬…

    编程 2025-04-29
  • g3log源代码学习

    g3log是一个高性能C++日志库,其代码十分精简和可读性强,本文将从3个方面详细介绍g3log源代码学习。 一、g3log源代码整体架构 g3log的整体架构十分清晰,其中有3个…

    编程 2025-04-29
  • 网站为什么会被黑客攻击?

    黑客攻击是指利用计算机技术手段,入侵或者破坏计算机信息系统的一种行为。网站被黑客攻击是常见的安全隐患之一,那么,为什么网站会被黑客攻击呢?本文将从不同角度分析这个问题,并且提出相应…

    编程 2025-04-29
  • 如何用Python访问网站

    本文将从以下几个方面介绍如何使用Python访问网站:网络请求、POST请求、用户代理、Cookie、代理IP、API请求。 一、网络请求 Python有三种主流的网络请求库:ur…

    编程 2025-04-29
  • 如何将Python开发的网站变成APP

    要将Python开发的网站变成APP,可以通过Python的Web框架或者APP框架,将网站封装为APP的形式。常见的方法有: 一、使用Python的Web框架Django Dja…

    编程 2025-04-28
  • 如何在服务器上运行网站

    想要在服务器上运行网站,需要按照以下步骤进行配置和部署。 一、选择服务器和域名 想要在服务器上运行网站,首先需要选择一台云服务器或者自己搭建的服务器。云服务器会提供更好的稳定性和可…

    编程 2025-04-28
  • Python网站源码解析

    本文将从多个方面对Python网站源码进行详细解析,包括搭建网站、数据处理、安全性等内容。 一、搭建网站 Python是一种高级编程语言,适用于多种领域。它也可以用于搭建网站。最常…

    编程 2025-04-28
  • 数字孪生源代码的介绍

    数字孪生源代码是一种用于模拟现实世界的技术。它将现实世界的实体或场景进行数字化,使得我们可以通过计算机程序对其进行模拟,以便进行分析和预测。数字孪生源代码包含了许多组件和算法,下面…

    编程 2025-04-28
  • eu.ipidea.io——全能编程开发工程师必备网站

    eu.ipidea.io作为一个编程工具聚合平台,提供了包括代码在线编辑、API查询和IDE集成等多个方面的功能,大大方便了全能编程开发工程师的工作。 一、在线代码编辑 eu.ip…

    编程 2025-04-27
  • Python爬虫攻击网站

    本文将从多个方面详细阐述如何使用Python爬虫攻击网站。 一、网络爬虫的基础知识 网络爬虫是一种自动获取网站数据的程序。在Python中,我们可以使用urllib和request…

    编程 2025-04-27

发表回复

登录后才能评论