⑴ 緗戠珯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視頻源碼(時尚網上商城)
跟著視頻做千萬別著急 先仔細看看錯誤信息 或者檢查下有沒有犯低級的拼寫錯誤 然後根據錯誤信息網路 谷歌下 這樣才能加深記憶