當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServletRequest.logout方法代碼示例

本文整理匯總了Java中javax.servlet.http.HttpServletRequest.logout方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletRequest.logout方法的具體用法?Java HttpServletRequest.logout怎麽用?Java HttpServletRequest.logout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.http.HttpServletRequest的用法示例。


在下文中一共展示了HttpServletRequest.logout方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doGet

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    req.login(USER, PWD);

    if (!req.getRemoteUser().equals(USER))
        throw new ServletException();
    if (!req.getUserPrincipal().getName().equals(USER))
        throw new ServletException();

    req.logout();

    if (req.getRemoteUser() != null)
        throw new ServletException();
    if (req.getUserPrincipal() != null)
        throw new ServletException();

    resp.getWriter().write(OK);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:21,代碼來源:TestRequest.java

示例2: login

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public boolean login(String p_username, String p_password, HttpServletRequest req) {		
	try {			
		req.logout();
		beginTx();
			User u = findUser(p_username);
		
			if (u == null) {
                   _logger.info("User with username " + p_username + " not found");
                   commitTx();	
                   return false;
               }
		
			req.login(u.getId().toString(), Security.getPasswordHash(p_password, u.getSalt()));
			
			u.updatePassword(p_password);				
			u.setLastLogin(new Date());
		commitTx();			
		return true;
	} catch (ServletException e) {
		_logger.error(e.getMessage(), e);
		return false;
	}		
}
 
開發者ID:awslabs,項目名稱:aws-photosharing-example,代碼行數:24,代碼來源:UserFacade.java

示例3: doPost

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    HttpSession session = request.getSession(false);
    if (session != null) {
        session.invalidate();
    }
    request.logout();
    response.sendRedirect(request.getContextPath() + "/");
}
 
開發者ID:nickscha,項目名稱:servlet-auth,代碼行數:10,代碼來源:MyLogoutServlet.java

示例4: logout

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@CrossOrigin
@RequestMapping(method = RequestMethod.GET, value = "/logout", produces = "text/plain")
@ApiOperation("Logout")
public String logout() throws ServletException {
  HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
  request.logout();
  return "Logged out";
}
 
開發者ID:redhat-developer-demos,項目名稱:istio-ola,代碼行數:9,代碼來源:OlaController.java

示例5: logout

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * Logs out the user and invalidates the session
 * @return
 *  the method always returns SUCCESS or throws an error if logout fails.
 * @throws ServletException
 */
public String logout() throws ServletException {
    final HttpServletRequest request = ServletActionContext.getRequest();
    final HttpSession session = request.getSession();

    //perform container login
    request.logout();
    session.invalidate();
    return SUCCESS;
}
 
開發者ID:gmuecke,項目名稱:boutique-de-jus,代碼行數:16,代碼來源:AuthAction.java

示例6: logout

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public void logout(HttpServletRequest req) {		
	req.getSession().invalidate();				
	try {
		req.logout();
	} catch (ServletException e) {
		_logger.error(e.getMessage(), e);
	}
}
 
開發者ID:awslabs,項目名稱:aws-photosharing-example,代碼行數:9,代碼來源:UserFacade.java

示例7: logout

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@POST
@Path("/logout")
public void logout(@Context HttpServletRequest httpRequest) {
    try {
        httpRequest.logout();
    } catch (ServletException ex) {
        Logger.getLogger(AuthResource.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:jmd-stuff,項目名稱:task-app,代碼行數:10,代碼來源:AuthResource.java

示例8: doDelete

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@Override
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.logout();
}
 
開發者ID:nickscha,項目名稱:servlet-auth,代碼行數:5,代碼來源:MyLoginServlet.java

示例9: handleLogout

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public void handleLogout(HttpServletRequest req) throws ServletException {
    if (req.getParameter("logout") != null) {
        req.logout();
    }
}
 
開發者ID:nmajorov,項目名稱:keycloak_training,代碼行數:6,代碼來源:Controller.java

示例10: handleLogout

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public void handleLogout(HttpServletRequest req) throws ServletException {
    if (isLogoutAction(req)) {
        req.logout();
    }
}
 
開發者ID:nmajorov,項目名稱:keycloak_training,代碼行數:6,代碼來源:Controller.java

示例11: logout

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@ApiOperation(value = "Logout")
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public void logout(HttpServletRequest request) throws ServletException {
    request.logout();
}
 
開發者ID:bndynet,項目名稱:web-framework-for-java,代碼行數:6,代碼來源:UserController.java


注:本文中的javax.servlet.http.HttpServletRequest.logout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。