導航:首頁 > 編程語言 > 登錄參數jsp

登錄參數jsp

發布時間:2023-08-04 19:14:01

jsP頁面獲取系統登錄用戶信息

登錄的時候需要在後台查詢資料庫驗證,驗證的同時查詢到這條記錄,把身份證號返回,存在session里,在頁面就可以拿到

❷ 在jsp頁面中如何獲取Servlet中的參數

可以使用getAttribute()方法和getParameter()方法,區別在於,getAttribute()方法是從request中得到參數,getParameter()方法是從url中得到參數

❸ jsp中點擊登錄彈出對話框如何實現

實現的方法有很多啊!最簡單的就是用javaScript
在JSP頁面中加一局<script>alert("對話框")</script>

❹ 在jsp中,如何實現普通用戶和管理員登陸後跳轉到不同的點jsp頁面

在jsp中可以通過角色控製表跳轉不同的頁面。
參考代碼如下:

package myservlet;
import mybean.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class IsLogin extends HttpServlet{
public void init(ServletConfig config) throws ServletException{
super.init(config);
}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
//接收參數
String user=request.getParameter("user");
String password=request.getParameter("password");
String actor=request.getParameter("actor");
//載入驅動,建立連接
Connection con;
Statement sql;
ResultSet rs;
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}catch(Exception e){
System.out.print(e);
}

try{
String uri="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=student";
con=DriverManager.getConnection(uri,"sa","940712");//資料庫的登錄名 sa 940712
sql=con.createStatement();
//通過if語句判斷角色,將其賬號密碼與資料庫的userInf內的信息進行比對(角色的賬號密碼統一存儲在UserInf表中)
//若正確,轉發至角色對應的登錄成功界面;若沒有,統一轉發至出錯界面,提供返回鏈接供重新登錄
if(actor=="student"){
rs=sql.executeQuery("select userIs,password from userInf where actor='student'");
while(rs.next()){
if(user==rs.getString(1) && password==rs.getString(2)){
RequestDispatcher dispatcher=request.getRequestDispatcher("loginSuccessS.jsp");
dispatcher.forward(request,response);
}
}
RequestDispatcher dispatcher=request.getRequestDispatcher("loginError.jsp");
dispatcher.forward(request,response);
}
//普通用戶角色控制
else if(actor=="teacher"){
rs=sql.executeQuery("select userIs,password from userInf where actor='teacher'");
while(rs.next()){
if(user==rs.getString(1) && password==rs.getString(2)){
RequestDispatcher dispatcher=request.getRequestDispatcher("loginSuccessT.jsp");
dispatcher.forward(request,response);
}
}
RequestDispatcher dispatcher=request.getRequestDispatcher("loginError.jsp");
dispatcher.forward(request,response);
}
//管理員角色控制
else if(actor=="admin"){
rs=sql.executeQuery("select userIs,password from userInf where actor='admin'");
while(rs.next()){
if(user==rs.getString(1) && password==rs.getString(2)){
RequestDispatcher dispatcher=request.getRequestDispatcher("loginSuccessA.jsp");
dispatcher.forward(request,response);
}
}
RequestDispatcher dispatcher=request.getRequestDispatcher("loginError.jsp");
dispatcher.forward(request,response);
}
}catch(SQLException e){
//System.out.print("您的賬號或密碼錯誤,請返回重新輸入");
RequestDispatcher dispatcher=request.getRequestDispatcher("loginError.jsp");
dispatcher.forward(request,response);
}
}
}

閱讀全文

與登錄參數jsp相關的資料

熱點內容
打開找不到路徑的文件怎麼辦 瀏覽:94
澄海3c545地圖放到那個文件夾里 瀏覽:540
華為手機qq文件打開方式打開方式 瀏覽:856
手機如何刪除刪除不了的app 瀏覽:212
編程怎麼走好路 瀏覽:417
小米游戲數據一般在哪個文件 瀏覽:902
桌面伺服器是哪個文件 瀏覽:965
二進制數據類型的長度為什麼是n4 瀏覽:561
js獲取當前js文件的路徑 瀏覽:106
adobeindesigncs6教程 瀏覽:909
猿編程怎麼玩游戲 瀏覽:603
win8無網路訪問許可權 瀏覽:121
一個資料庫大小限制多少g 瀏覽:760
無限斯特拉托斯可以用哪些app看 瀏覽:954
圖片與拍攝文件大小名詞解釋 瀏覽:229
java的classpath配置文件 瀏覽:286
在小年魚app裡面如何退款 瀏覽:143
網路電話哪個軟體好用嗎 瀏覽:386
pokemon叫聲文件 瀏覽:689
工程源文件路徑 瀏覽:137

友情鏈接