当前位置: 首页>>代码示例>>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;未经允许,请勿转载。