導航:首頁 > 編程語言 > 登錄參數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相關的資料

熱點內容
網路中常用的傳輸介質 瀏覽:518
文件如何使用 瀏覽:322
同步推密碼找回 瀏覽:865
樂高怎麼才能用電腦編程序 瀏覽:65
本機qq文件為什麼找不到 瀏覽:264
安卓qq空間免升級 瀏覽:490
linux如何刪除模塊驅動程序 瀏覽:193
at89c51c程序 瀏覽:329
怎麼創建word大綱文件 瀏覽:622
裊裊朗誦文件生成器 瀏覽:626
1054件文件是多少gb 瀏覽:371
高州禁養區內能養豬多少頭的文件 瀏覽:927
win8ico文件 瀏覽:949
仁和數控怎麼編程 瀏覽:381
項目文件夾圖片 瀏覽:87
怎麼在東芝電視安裝app 瀏覽:954
plc顯示數字怎麼編程 瀏覽:439
如何辨別假網站 瀏覽:711
寬頻用別人的賬號密碼 瀏覽:556
新app如何佔有市場 瀏覽:42

友情鏈接