本文整理匯總了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();
}