⑴ 缃戠珯jsp婧愮爜鏄浠涔堟剰镐濓纻
缃戠珯JSP婧愮爜鏄涓绉嶅姩镐佺绣椤电紪绋嬭瑷锛屽畠镄勫叏绉版槸java Server Pages锛屽畠鍏佽稿湪Java浠g爜涓宓屽叆HTML镙囱帮纴浠ヤ究鐢ㄤ簬瀹㈡埛绔娴忚埚櫒璁块梾鍜屾樉绀恒侸SP婧愮爜涓昏佺敤浜庡紑鍙慦eb搴旂敤绋嫔簭鍜屼紒涓氱骇搴旂敤绋嫔簭锛屽彲浠ユ柟渚垮湴杩涜屽紑鍙戝拰缁存姢銆傚畠涓虹▼搴忓憳鎻愪緵浜嗛潪甯哥伒娲荤殑寮鍙戝钩鍙帮纴骞跺彲浠ヨ交𨱒惧湴鐢ㄤ簬鏋勫缓楂樻晥鍜屽畨鍏ㄧ殑Web搴旂敤绋嫔簭銆
JSP婧愮爜鍏锋湁璁稿氱壒镣瑰拰鐢ㄩ斻傞栧厛锛屽畠鎻愪緵浜嗕竴涓绫讳技浜嶩TML镄勭紪绋嬫ā鍨嬶纴绋嫔簭锻桦彲浠ユ洿杞绘涧鍦颁娇鐢ㄧ粍浠躲佹爣璁板拰鑴氭湰𨱒ユ瀯寤哄嶆潅镄刉eb搴旂敤绋嫔簭銆傚叾娆★纴JSP婧愮爜鏄锘轰簬Java镄勶纴杩欐剰锻崇潃搴旂敤绋嫔簭鍙浠ュ湪涓嶅悓镄勫钩鍙颁笂杩愯岋纴钥屼笖寰埚规槗娣诲姞鍜屽垹闄ゅ姛鑳姐傝缮鍙浠ヤ娇鐢↗ava绫绘潵镎崭綔鏁版嵁搴揿拰鏂囦欢銆傛ゅ栵纴JSP婧愮爜涔熸敮鎸丣avaBean锛岃繖浣垮缑绋嫔簭锻桦彲浠ユ洿杞绘涧鍦板皝瑁呮暟鎹鍜屽姛鑳戒互渚块吨鐢ㄣ
JSP婧愮爜镄勫簲鐢ㄨ寖锲撮潪甯稿箍娉涳纴瀹冭鐢ㄤ簬璁稿氢紒涓氱骇搴旂敤绋嫔簭鍜屼簰镵旂绣搴旂敤绋嫔簭镄勬瀯寤轰腑銆备緥濡傦纴鐢靛瓙鍟嗗姟銆佺ぞ浜ょ绣缁溿佸湪绾块摱琛屽拰淇濋橹绛夊悇绉嶅簲鐢ㄧ▼搴忛兘浣跨敤JSP婧愮爜杩涜屽紑鍙戙傛湭𨱒ワ纴闅忕潃浜戣$畻鍜岀墿镵旂绣鎶链镄勪笉鏂鍙戝𪾢锛孞SP婧愮爜镄勫簲鐢ㄥ拰闇姹备篃灏嗙户缁澧炲姞銆傚逛簬绋嫔簭锻樻潵璇达纴镡熺粌鎺屾彙JSP婧愮爜灏嗘槸涓椤归潪甯告湁鍓嶉旂殑鎶鑳姐
⑵ jsp网站下载源码如何使用
#1 首先要安装并配置好JAVA_HOME
#2 查看源码用的是什么类型的数据库不可能同时用SQL2000和mysql的
#3 恢复数据库
#4 把应用放置到tomcat下的webapps目录下
#5 查看并修改应用系统的数据库配置文件,使之与当前的数据库参数一致。
#6 启动tomcat服务器 \bin\startup.bat
#7 打开浏览器 访问http://localhost:8080/应用的目录
OVER
⑶ 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>
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 的源码
一般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">
<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>
⑹ 韩顺平jsp视频源码(时尚网上商城)
跟着视频做千万别着急 先仔细看看错误信息 或者检查下有没有犯低级的拼写错误 然后根据错误信息网络 谷歌下 这样才能加深记忆