jsp課程設計題目及源代碼(jsp程序設計課本例題代碼)

本文目錄一覽:

jsp的兩個選擇題,不會做

第一個,選(d)

(1,2)好像jsp:getgetParam name=”” jsp:getParameter name=」」

不存在樣的,

(3)它是得session裡面的值,所以不行的,

第二個,選(b)

(1)因為A 它是包含結果,首先它會執行兩次,當他執行第二個時,它是得不到值的, 那樣得到只是一個null

(2)第二個是,代碼包含,它會把第個頁面的代碼copy近來,那樣就能得到了值了

(3,4)頁面跳轉,也不會得到值的,

在JSP中怎麼實現多項選擇題,可以給以下源代碼,

你說的多項選擇題,我是不是可以理解成多選??

多選的實現是這樣的:

第一: 必須將多選框放到form裡面。

第二: 然後name屬性完全一樣,value不相同。這樣當你提交到Action中的時候,只需要使用request對象獲取toselect的值就行了。

第三: 獲取值:request.getParameterValues(“toselect”),就會將選中的多選框裡面的value獲取,並且返回一個String[]數組,這個數組裡面就有你想要的值:即選中的值

html

body

form

input type = “checkbox” value = “A” name = “toselect”/A

input type = “checkbox” value = “B” name = “toselect”/B

input type = “checkbox” value = “C” name = “toselect”/C

input type = “checkbox” value = “D” name = “toselect”/D

/form

/body

/html

用jsp設計一個小的人事信息管理系統 (軟體工程)(課程設計)

幫你做,那肯定是要收費的,這個系統如果拿設計到源碼,如果開發的快,最少也要個2個星期!並且必須用SSH框架做,不然JSP寫SQL語句,那還不搞死人

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

原創文章,作者:簡單一點,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/129053.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
簡單一點的頭像簡單一點
上一篇 2024-10-03 23:26
下一篇 2024-10-03 23:26

相關推薦

  • g3log源代碼學習

    g3log是一個高性能C++日誌庫,其代碼十分精簡和可讀性強,本文將從3個方面詳細介紹g3log源代碼學習。 一、g3log源代碼整體架構 g3log的整體架構十分清晰,其中有3個…

    編程 2025-04-29
  • Python計算機語言程序設計用法介紹

    Python是一種高級編程語言,其設計目的是讓程序員能夠在編寫代碼時更加關注演算法的設計,而不必過多地考慮語言細節。Python被廣泛應用於網站開發、數據科學、人工智慧、機器學習等各…

    編程 2025-04-28
  • 使用面向對象程序設計方法改寫猜數字遊戲Python程序

    本文將從以下多個方面對猜數字遊戲程序功能要求,使用面向對象程序設計方法改寫該程序Python做詳細的闡述。 一、遊戲規則 1、遊戲開始時,程序隨機生成一個 1 到 100 之間的整…

    編程 2025-04-28
  • 數字孿生源代碼的介紹

    數字孿生源代碼是一種用於模擬現實世界的技術。它將現實世界的實體或場景進行數字化,使得我們可以通過計算機程序對其進行模擬,以便進行分析和預測。數字孿生源代碼包含了許多組件和演算法,下面…

    編程 2025-04-28
  • 匯率兌換程序和溫度轉換程序設計

    這篇文章將從多個方面詳細闡述如何設計匯率兌換程序和溫度轉換程序。這些程序可以幫助人們更方便地計算貨幣匯率和溫度轉換,對於需要頻繁出差或者經常進行氣象預報的人來說,這些程序將非常有用…

    編程 2025-04-27
  • 動態規劃例題用法介紹

    本文將以動態規劃(Dynamic Programming, DP)例題為中心,深入闡述動態規劃的原理和應用。 一、最長公共子序列問題 最長公共子序列問題(Longest Commo…

    編程 2025-04-27
  • Python程序設計題庫博客園

    Python程序設計題庫博客園是一個開發者可以通過該平台進行學習和檢測自身能力的編程題目練習平台。其提供了一些Python的基礎編程技能練習,對於想要學習Python編程,提高編程…

    編程 2025-04-27
  • CCF中學生計算機程序設計全面解析

    CCF(中國計算機學會)中學生計算機程序設計是一個旨在培養中學生計算思維和編程能力的活動。自2000年開始,每年舉辦一次,分為入門篇、基礎篇、提高篇、專業篇四個階段,以及最新版和答…

    編程 2025-04-23
  • Javascript高級程序設計PDF的探討

    一、Javascript語言基礎 Javascript作為一門編程語言,具有獨特的特點和語法結構。在學習Javascript時,我們需要掌握它的語言基礎,如變數、數據類型、運算符等…

    編程 2025-04-12
  • 如何查看exe文件的源代碼

    一、使用反彙編工具檢查 反彙編工具是一種將機器語言轉發成彙編語言的軟體工具,也可以將目標文件(例如exe)文件轉化為可讀性較好的彙編代碼。 下面是一個使用IDA反彙編工具對exe文…

    編程 2025-02-25

發表回復

登錄後才能評論