List of usage examples for javax.servlet.http HttpServletResponse sendRedirect
public void sendRedirect(String location) throws IOException;
From source file:co.com.ppit2.web.controller.handler.MyAccessDeniedHandler.java
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { String uri = request.getRequestURI(); String cPath = request.getContextPath(); int longCPath = cPath.length(); String pagSolicitada = uri.substring(longCPath); response.sendRedirect(accessDeniedUrl); request.getSession().setAttribute("pagSolicitada", pagSolicitada); }
From source file:de.undercouch.gradle.tasks.download.RedirectTest.java
@Override protected Handler[] makeHandlers() throws IOException { ContextHandler redirectHandler = new ContextHandler("/" + REDIRECT) { @Override/*from w ww . j av a2 s. com*/ public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException { if (redirects > 0) { redirects--; if (circular) { response.sendRedirect("/" + REDIRECT); } else { response.sendRedirect("/" + REDIRECT + "?r=" + redirects); } } else { response.setStatus(200); PrintWriter rw = response.getWriter(); rw.write("r: " + redirects); rw.close(); } } }; return new Handler[] { redirectHandler }; }
From source file:com.museum_web.controller.AnswerController.java
@RequestMapping("/actions/SaveAnswer") public void saveAnswer(Answer answer, HttpServletResponse response) throws Exception { if (answer.isCorrect() == null) answer.setCorrect(false);/*ww w . j a va2s. com*/ if (answer.getId() == 0) { answer.setId(null); new AnswerService().createAnswer(answer); } else new AnswerService().editAnswer(answer); response.sendRedirect("../answer"); }
From source file:com.museum_web.controller.MuseumController.java
@RequestMapping("actions/SaveMuseum") public void saveTheme(Museum museum, HttpServletRequest request, HttpServletResponse response) throws Exception { //ModelAndView mv = new ModelAndView("museum/list"); if (museum.getId() == 0) { museum.setId(null);/*from w w w .ja v a 2s .c o m*/ new MuseumService().createMuseum(museum); } else { new MuseumService().editMuseum(museum); } response.sendRedirect("../museum"); }
From source file:org.meruvian.yama.webapi.interceptor.LoggedInFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; HttpSession session = req.getSession(true); SecurityContextImpl sci = (SecurityContextImpl) session.getAttribute(SPRING_SECURITY_CONTEXT_KEY); if (sci == null) { chain.doFilter(request, response); return;/* w w w. j av a2 s . c o m*/ } res.sendRedirect(StringUtils.join(req.getContextPath(), SecurityConfig.LOGIN_SUCCESS_URL)); }
From source file:org.mitre.account_chooser.AccountChooserController.java
/** * Handles form submits//from w w w .ja va 2 s. c o m * * @param redirectUri * A redirection URI where the response will be sent. * @param alias * The OIDC alias selected. * @param response * Provide the HTTP-specific functionality for sending a * response. In this case a redirect to redirect the End-User * back to the OpenID Connect Client. * @throws IOException * If an output exception occurs in sending the redirect. */ @RequestMapping(value = "/selected") public void processSubmit(@RequestParam("redirect_uri") String redirectUri, @RequestParam("issuer") String issuer, @RequestParam("client_id") String clientId, HttpServletResponse response) throws IOException { // Handle Submit Map<String, String> urlVariables = new HashMap<String, String>(); urlVariables.put("issuer", issuer); response.sendRedirect(AccountChooserController.buildURL(redirectUri, urlVariables)); }
From source file:com.sun.socialsite.web.filters.RedirectorFilter.java
/** * *//* w w w.j ava 2 s. com*/ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpReq = (HttpServletRequest) req; HttpServletResponse httpResp = (HttpServletResponse) resp; String redirectionUri = getRedirectionUri(httpReq); if (redirectionUri == null) { chain.doFilter(req, resp); } else { httpResp.sendRedirect(redirectionUri); } }
From source file:org.wallride.web.support.SetupRedirectInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { Blog blog = blogService.getBlogById(Blog.DEFAULT_ID); if (blog != null) { return true; }/*from w w w . ja v a2 s .c o m*/ final String requestPath = getRequestPath(request); if (!SETUP_PATH.equalsIgnoreCase(requestPath)) { response.sendRedirect(request.getContextPath() + SETUP_PATH); return false; } return true; }
From source file:pivotal.au.se.gemfirexdweb.controller.PrefsController.java
@RequestMapping(value = "/preferences", method = RequestMethod.POST) public String updatePreferences(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {/*from w w w . ja v a2 s. c o m*/ Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to update preferences"); UserPref userPrefs = (UserPref) session.getAttribute("prefs"); userPrefs.setRecordsToDisplay(Integer.parseInt(request.getParameter("recordsToDisplay"))); userPrefs.setMaxRecordsinSQLQueryWindow( Integer.parseInt(request.getParameter("maxRecordsinSQLQueryWindow"))); userPrefs.setAutoCommit((String) request.getParameter("autoCommit")); userPrefs.setJolokiaURL((String) request.getParameter("jolokiaURL")); ConnectionManager cm = ConnectionManager.getInstance(); Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (request.getParameter("autoCommit").equals("Y")) { conn.setAutoCommit(true); } else { conn.setAutoCommit(false); } cm.updateConnection(conn, (String) session.getAttribute("user_key")); model.addAttribute("saved", "Successfully saved application preferences"); session.setAttribute("userPref", userPrefs); // This will resolve to /WEB-INF/jsp/preferences.jsp return "preferences"; }
From source file:br.vschettino.forum.interceptor.AuthInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { Usuario visitante = (Usuario) request.getSession().getAttribute("usuario"); if (request.getRequestURI().contains("/login") || request.getRequestURI().contains("/logout")) { return true; }/*w ww . j av a 2s .c o m*/ if (visitante == null) { response.sendRedirect(request.getContextPath() + "/web/login?unauthorized=true"); return false; } return true; }