本文整理汇总了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);
}
示例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;
}
}
示例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() + "/");
}
示例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";
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例8: doDelete
import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.logout();
}
示例9: handleLogout
import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public void handleLogout(HttpServletRequest req) throws ServletException {
if (req.getParameter("logout") != null) {
req.logout();
}
}
示例10: handleLogout
import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public void handleLogout(HttpServletRequest req) throws ServletException {
if (isLogoutAction(req)) {
req.logout();
}
}
示例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();
}