?? loginbean.java
字號(hào):
/*
* @(#)LoginBean.java
*
* Copyright 2003 by SYNTC, All rights reserved.
*
* This software is the confidential and proprietary information of SYNTC.
* ("Confidential Information").
*/
package cn.com.syntc.webapp.business;
import javax.servlet.*;
import javax.servlet.http.*;
import cn.com.syntc.common.action.*;
import cn.com.syntc.common.io.*;
import cn.com.syntc.common.util.*;
import cn.com.syntc.common.type.*;
import cn.com.syntc.webapp.taglib.CheckLogin;
import cn.com.syntc.webapp.define.Constant;
import cn.com.syntc.webapp.session.UserSession;
/**
* 進(jìn)行登錄的業(yè)務(wù)邏輯處理的例子<br>
* @author wang yong
* @version 1.0
*/
public class LoginBean extends BusinessLogic
{
/**
* 構(gòu)造函數(shù)
*/
public LoginBean()
{
System.out.println("FrameWork:業(yè)務(wù)處理類實(shí)例化完成【" + this.getClass().getName() + "】");
}
/**
* 業(yè)務(wù)邏輯處理機(jī)能
*/
public void execute(HttpServletRequest request, HttpServletResponse response, Parameters parameters) throws CommonException
{
String forwardPage = "/framework/exam/index.jsp";
try
{
request.getSession().setMaxInactiveInterval(24*60*60);
// 用戶信息
UserSession USession = new UserSession();
SqlUtil sqlutil = new SqlUtil();
String userid = (String)parameters.getParameters("request", "userid");
String pwd = (String)parameters.getParameters("request", "pwd");
String strSql = "SELECT A.USERID,A.USERNAME,A.NICENAME,A.PASSWORD,A.SEX,A.BIRTHDAY,A.OICQ,A.MAIL,A.ORGNAME,A.UNITNAME,A.HOMEPAGE,A.COMEFROM,A.INTRODUCTION,A.LASTLOGINTIME,B.ROLEID,B.ROLENAME,SYSDATE() AS LOGINTIME FROM USER_TBL A,ROLE_TBL B WHERE A.USERNAME='" + userid + "' AND A.PASSWORD='"+pwd+"' AND A.ROLEID = B.ROLEID AND A.ONOFF='1'";
ResultSet resultset = sqlutil.executeQuery(strSql);
// 驗(yàn)證成功
if(resultset.next())
{
/**** 取得用戶信息 ****/
// 設(shè)置用戶ID
USession.setUserID(resultset.getString("USERID"));
// 設(shè)置用戶名
USession.setUserName(resultset.getString("USERNAME"));
// 設(shè)置用戶別名
USession.setNiceName(resultset.getString("NICENAME"));
// 設(shè)置用戶密碼
// USession.setPassword(resultset.getString("PASSWORD"));
// 設(shè)置用戶性別
USession.setSex(resultset.getString("SEX"));
// 設(shè)置出生年月
USession.setBirthday(resultset.getString("BIRTHDAY"));
// 設(shè)置用戶QQ
USession.setOicq(resultset.getString("OICQ"));
// 設(shè)置用戶郵件
USession.setMail(resultset.getString("MAIL"));
// 來(lái)自哪里
USession.setComeFrom(resultset.getString("COMEFROM"));
// 設(shè)置個(gè)人主頁(yè)
USession.setHomePage(resultset.getString("HOMEPAGE"));
// 設(shè)置個(gè)人介紹
USession.setIntroduction(resultset.getString("INTRODUCTION"));
// 設(shè)置角色I(xiàn)D
USession.setRoleID(Integer.parseInt(resultset.getString("ROLEID")));
// 設(shè)置角色名
USession.setRoleName(resultset.getString("ROLENAME"));
// 設(shè)置所屬單名稱
USession.setOrgName(resultset.getString("ORGNAME"));
// 設(shè)置所屬部門名稱
USession.setUnitName(resultset.getString("UNITNAME"));
// 設(shè)置登錄時(shí)間
USession.setLoginTime(resultset.getString("LOGINTIME"));
// 設(shè)置登錄IP
USession.setLogonIP(request.getRemoteAddr());
// 修改最后登陸時(shí)間
strSql = "UPDATE USER_TBL SET LASTLOGINTIME = SYSDATE()";
sqlutil.preparedStatement(strSql);
sqlutil.executeUpdate();
forwardPage = "/ExamList.do";
request.getSession().setAttribute("ActiveMenu", "0");
}
// 驗(yàn)證失敗
else
{
forwardPage = "/login.jsp";
}
sqlutil.close();
request.getSession().setAttribute("UserSession", USession);
parameters.setParameters("results", "ForwardPage", forwardPage);
}
catch(Exception ex)
{
forwardPage = "/error.jsp";
}
}
/**
* 頁(yè)面表單檢測(cè)處理機(jī)能
*/
public void validate(HttpServletRequest request, HttpServletResponse response, Parameters parameters) throws CommonException
{
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -