网站源码jsp
⑴ jsp登陆界面源代码
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>
<td><input type="submit" value="登录" style="background-color:pink"> <input
type="reset" value="重置" style="background-color:red"></td>
</tr>
</table>
</form>
</body>
</html>
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();
}
}
}
⑵ "网站源码“是什么意思
网站源码,我们可以把它理成源文代码,就拿我们当前看到的这个网页来说吧,其实它是由一大堆的源代码组成,通过我们的IE(Microsoft Internet Explorer)浏览器(或服务器)翻译成现在我们所看到的这个样子。
网站源码也分为两种,一种是动态源码如:ASP,PHP,JSP,.NET,CGI等,一种是静态源码如:HTML等。
什么是动态源码呢?最大的特点就是能够和用户之间互动。比如说网易的信箱,张三登陆的时候,会看到欢迎光临张三,李四又登陆了,李四又看到欢迎光临李四,其实他们两个人登陆的是一个页面,这个就是动态源码的好处,如果要是用静态源码,好么网易有几百万的邮箱用户,每个人做一个页面那要多少页啊?动态源码不单单只有这么一点用处,比如说我们常见的一些论坛、留言本、计数器、聊天室等,都是由动态源码开发的。
什么是静态源码呢,比如说我们当前看到的这个网页他就是静态的源码,静态源码无法实现以上的那些功能。
现在有不少源码下载站,提供别人开发好的源码让我们下载。他们开发的都不错,美工也相当不错,基本上下载下来,只要稍加改动就可以使用了,更方便了我们建站,您可以跟据自己所需去下载,更重要的是,要先看看您自己使用的网站空间,是那一种的,比如说您使用的是ASP空间,那么您一定要下载ASP源码,不然下载别的是不能运行的。。
⑶ JSP的源代码写在哪
jsp文件是一个可以对页面和java代码都能操作的页面,可以有html标签和java代码嵌套。java文件是你的类文件,只能有java代码, 服务器执行jsp文件的时候其实本质是执行的java文件,我们把这种特殊的java文件称作servlet,他具有一定固有的结构。执行过程是这样的 首先我们要知道servlet是个什么东西,你可以理解为他是一个java web需要遵守的规范,他其实是一个接口interface,我们常用的tomcat就是一个servlet容器,他实现了servlet这个接口。所以我们的服务器Tomcat处理web请求的时候就是把jsp首先翻译转换成一个servlet文件(后缀是java的文件,只是拥有特定的格式所以叫做servlet),然后服务器执行这个servlet文件,根据servlet里的方法调用其他的java文件,根据不同的需要各种java文件定义各种不同的类和功能,最终servlet执行结束用输出流打印一个htm文件格式输出到页面,浏览器识别这个htm显示出来,所以我们浏览器显示的并不是jsp而是jsp翻译成servlet运行后输出的htm
⑷ 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>
<td><input 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>
(4)网站源码jsp扩展阅读:
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" "http://www.w3.org/TR/html4/loose.dtd">
<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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert 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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>登录界面</title>
</head>
<body background="C:Userswin8workspaceLoginimage\_10.jpg" >
<center>
<br><br><br><br><br><br>
<h1 style="color:yellow">Login</h1>
<br>
<form name="loginForm" action="login_check.jsp" method="post">
<table Border="0" >
<tr >
<td>账号</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" name="password">
</td>
</tr>
</table>
<br>
<input type="submit" value="登录" style="color:#BC8F8F">
</form>
</center>
</body>
</html>
⑸ jsp网站下载源码如何使用
首先看你的源码用的是什么数据库,一般在jdbc.properties文件里,也有可能硬编码,直接全局搜jdbc就可以了
然后用myeclipae把源码导出为一个war包,然后把war包放在tomcat的webapps目录下,启动timcat就可以啦
⑹ JSP源码的网站在本地怎么测试,用什么软件
用网页三剑客等之类的,也可以用他们专门的软件比如vb.net2005,PHP专用软件EclipsePHP Studio,等等有很多种,当然也可以用记事本之类的也行.
⑺ 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">
<title>JSP连接Access数据库</title>
<style type="text/css">
<!--
.style1 {
font-size: 20px;
font-weight: bold;
}
-->
</style>
</head><body>
<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>
⑻ 请问网站源码是什么意思,怎么用
网站源码指的是网站的源程序代码,包括前台的html代码和后台的程序代码.
至于您所说的怎么用,那要看你所找的是什么源码,现在的网站源码大至分为 asp、PHP、jsp、.net等等。不同语言的源码需要有对应的运行坏竟支持。
或者你可以到网站上查一下使用说明,如cms、动易等。
⑼ 网上下的jsp源码要怎么用
需要部署到服务器中
找到菜单window→ShowView→Servers,打开Servers视图标签,部署的Tomcat服务
在新打开的对话框中,有一个Project项,选择要部署的项目
点击“Finish”完成部署
这样项目就部署到Tomcat里面去了
⑽ 下载好的jsp网站源码怎么运行
jsp的运行需要有容器支持。同时看这个项目是否需要某些资源文件,类似数据库连接等。
如果是则需要配置才可以正常运行,如果不是则可以直接拷贝connect-web文件夹到tomcat的webapps目录下,启动tomcat,控制台没有异常就算部署成功了。同时要想正确访问该应用,查看web.xml中配置的访问首页,否则会因找不到页面报404错误。