📄 loginmanager.java
字号:
package oracle.otnsamples.AQ.Manager;
/**
* @author Rajat Gupta
* @version 1.0
*
* Name of the Application : LoginManager.java
* Development Environment : Oracle 9i JDeveloper
* Creation/Modification History :
*
* Rajat Gupta 15-Jan-2001 Created
*
*/
// Servlet Imports
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
// Util Imports
import java.util.Hashtable;
// Other Files
import oracle.otnsamples.AQ.Helper.LoginHelper;
/**
* This class is invoked when a user enters the Retail Shop as a
* Customer or as an Admin. It implements the Manager Interface.
* This class gets the LoginID and Password from the request object
* and passes it to the LoginHelper.java which creates the query
* to validate the user.
* This class is also invoked if the User "Signs Out" of the application.
* In this case, the session object of the user is invalidated.
*
* @see Manager.java
*/
public class LoginManager implements Manager{
/**
* Empty Constructor
*/
public LoginManager(){
}
/**
* This is the main method which validates the User. It gets the entered
* LoginID and Password from the request object and passes it to the Helper
* class. If the user is valid, then the required attributes are entered in
* the Session Object. In case the user is not valid, then the Exception
* thrown is propagated.
*
* @param p_request HttpServlet Request Object
* @exception Exception In case an unreported Exception is thrown
* @see LoginHelper.java
*/
public void validateUser(HttpServletRequest p_request) throws Exception{
// Get Login, password and type of user from the request object
String login = p_request.getParameter("Login");
String password = p_request.getParameter("Passwrd");
String user = p_request.getParameter("UserType");
Hashtable userinfo = LoginHelper.validateUser(login, password, user);
HttpSession session = p_request.getSession(true);
session.setAttribute("User", user);
session.setAttribute("Name",userinfo.get("Name"));
session.setAttribute("ID",login);
return;
}
/**
* This method is called when the user "Signs Out" of the application.
* This method gets the Session Object from the HttpRequest and
* invalidates it.
*
* @param p_request HttpServlet Request Object
* @exception Exception In case an unreported Exception is thrown
*/
public void inValidateUser(HttpServletRequest p_request) throws Exception{
p_request.getSession(false).invalidate();
return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -