當前位置:首頁 » 操作系統 » jsp源碼

jsp源碼

發布時間: 2022-01-12 07:26:32

Ⅰ 給定JSP程序源碼如下:

a和d是表達式,所以有輸出;c和d是java程序片,要想輸出得用java的輸出,所以這里沒有輸出。
a是先加後輸出,d是先輸出後加,所以一個是2,一個是1.

Ⅱ JSP源碼 |是什麼

JSP是網頁代碼。。。是製作網業用的。。。比如說:HTML XML CGI ASP PHP 等等好多種啊。。。這只是其中的一種。。。

Ⅲ JSP代碼意思

猜數字游戲,相當於你自己在控制台輸入數字,然後和隨即的數字進行比較,然後得出結果。就是這個意思。你把代碼拷貝到Eclipse中運行一下,就知道了。

Ⅳ JSP源碼如何使用

沒問題啊,我一直都用的XP做開發
你下載一個tomcat就行了,我用的6.0的,你下載安裝好後,在webapps文件夾裡面新建個你自己的文件夾,然後把JSP頁面放進去,啟動TOMCAT就行了,在瀏覽器裡面輸入http://locahost:8080/你的建的文件夾名/jsp文件名就可以訪問
那要看你裝sql SERVER 2000 沒有,裝好後把資料庫文件拷過去

Ⅳ jsp源代碼的編譯

jsp 是一個 內容生成與表示分離的技術,他實際還是一個Servlet .

JSP程序要運行於特定的Web伺服器中,例如Tomcat、WebLogic Server。
每次訪問JSP時,伺服器會把JSP程序編譯為一個Java類,這個Java類有特定的名稱,即Servlet.

Ⅵ jsp源碼怎麼使用

放到webapp目錄下面然後到bin下面啟動tomcat就可以了,如果程序沒有問題的話

Ⅶ 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>

(7)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 中網站的首頁源代碼

這是最簡單的一個例子,資料庫要你自己建,用的是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的源代碼寫在哪

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源碼要怎麼用

需要部署到伺服器中

找到菜單window→ShowView→Servers,打開Servers視圖標簽,部署的Tomcat服務

在新打開的對話框中,有一個Project項,選擇要部署的項目

點擊「Finish」完成部署

這樣項目就部署到Tomcat裡面去了

熱點內容
實測華為編譯器 發布:2024-09-19 23:50:52 瀏覽:821
linux匯總 發布:2024-09-19 23:46:39 瀏覽:452
阿里雲伺服器環境搭建教程 發布:2024-09-19 23:21:58 瀏覽:837
黃色文件夾圖標 發布:2024-09-19 23:19:22 瀏覽:684
mysql資料庫導出導入 發布:2024-09-19 23:00:47 瀏覽:183
lua腳本精靈 發布:2024-09-19 23:00:41 瀏覽:659
任務欄文件夾圖標 發布:2024-09-19 22:54:25 瀏覽:101
解壓來一波 發布:2024-09-19 22:46:36 瀏覽:933
mysqlpythonubuntu 發布:2024-09-19 22:46:27 瀏覽:501
伺服器請求獲取ip地址 發布:2024-09-19 22:33:25 瀏覽:515