List of usage examples for javax.servlet.http HttpServletResponse sendRedirect
public void sendRedirect(String location) throws IOException;
From source file:br.vschettino.forum.controller.SiteController.java
@RequestMapping(value = "/logout") @ResponseBody/*from w w w.ja v a 2s. c om*/ public ModelAndView logout(HttpServletRequest request, HttpServletResponse response) { try { request.getSession().removeAttribute("usuario"); response.sendRedirect(request.getContextPath() + "/web/login?logout=true"); } catch (IOException ex) { Logger.getLogger(SiteController.class.getName()).log(Level.SEVERE, null, ex); } return null; }
From source file:com.arihant15.ActionServlet.java
@RequestMapping("/logout.arihant15") public void dologout(HttpServletRequest req, HttpServletResponse res) throws IOException { try {/* w w w . j a v a 2s . co m*/ req.getSession().invalidate(); res.sendRedirect(req.getContextPath() + "/"); } catch (Exception e) { (res.getWriter()).println(e); } }
From source file:org.shaf.server.security.AuthenticationFailureHandler.java
/** * Executes if authentication has failed. *//*from www. ja va2 s. c om*/ @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { LOG.debug("SECURITY: Authentication failure..."); response.sendRedirect(request.getContextPath() + "/login.jsp?error=true"); }
From source file:com.exedio.cope.live.Anchor.java
void redirectHome(final HttpServletRequest request, final HttpServletResponse response) throws IOException { response.sendRedirect(response.encodeRedirectURL(session.getHome(request))); }
From source file:com.ibm.bluemix.hack.image.ImageEvaluator.java
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse * response)/*from ww w . ja va2s . c o m*/ */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.sendRedirect("image.jsp"); }
From source file:org.apache.ofbiz.passport.event.LinkedInEvents.java
/** * Redirect to LinkedIn login page./* w ww . j a v a 2 s. co m*/ * * @return */ public static String linkedInRedirect(HttpServletRequest request, HttpServletResponse response) { GenericValue oauth2LinkedIn = getOAuth2LinkedInConfig(request); if (UtilValidate.isEmpty(oauth2LinkedIn)) { return "error"; } String clientId = oauth2LinkedIn.getString(PassportUtil.ApiKeyLabel); String returnURI = oauth2LinkedIn.getString(envPrefix + PassportUtil.ReturnUrlLabel); // Get user authorization code try { String state = System.currentTimeMillis() + String.valueOf((new Random(10)).nextLong()); request.getSession().setAttribute(SESSION_LINKEDIN_STATE, state); String redirectUrl = TokenEndpoint + AuthorizeUri + "?client_id=" + clientId + "&response_type=code" + "&scope=" + DEFAULT_SCOPE + "&redirect_uri=" + URLEncoder.encode(returnURI, "UTF-8") + "&state=" + state; response.sendRedirect(redirectUrl); } catch (NullPointerException e) { String errMsg = UtilProperties.getMessage(resource, "RedirectToLinkedInOAuth2NullException", UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } catch (IOException e) { Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.toString()); String errMsg = UtilProperties.getMessage(resource, "RedirectToLinkedInOAuth2Error", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } return "success"; }
From source file:com.github.terma.gigaspacewebconsole.server.ImportServlet.java
@Override protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { try {/*from www . j a v a 2s .c o m*/ safeDoPost(request); response.sendRedirect(request.getContextPath()); } catch (IOException exception) { throw exception; } catch (Exception exception) { throw new IOException(exception); } }
From source file:com.exxonmobile.ace.hybris.storefront.security.DefaultAccessDeniedHandler.java
@Override public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { // redirecting to the home page when a 403 http error occurs. response.sendRedirect(request.getContextPath()); }
From source file:com.alibaba.cobar.manager.web.PermissionInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (!permissioned(request)) { // TODO redirect response.sendRedirect(URLBroker.redirectForbiddenScreen()); return false; }//from w w w. j a va 2 s. co m return super.preHandle(request, response, handler); }
From source file:com.google.sampling.experiential.server.MigrationBackendServlet.java
private void redirectUserToLogin(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.sendRedirect(userService.createLoginURL(req.getRequestURI())); }