List of usage examples for javax.servlet.http HttpServletResponse sendRedirect
public void sendRedirect(String location) throws IOException;
From source file:org.iti.agrimarket.view.UserController.java
@RequestMapping(value = { "/logout.htm" }) public String logout(HttpServletRequest request, Locale locale, HttpServletResponse response, Model model) { model.addAttribute("lang", locale); request.getSession().removeAttribute("user"); try {/*from w w w . jav a2 s.com*/ response.sendRedirect(request.getContextPath() + "/index.htm"); } catch (IOException ex) { Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } model.addAttribute("lang", locale); return "profile"; }
From source file:org.sventon.web.filter.ConfigAuthorizationFilterTest.java
@Test public void testDoFilterInternalApplicationConfiguredEditDisabled() throws Exception { final ConfigAuthorizationFilter filter = new ConfigAuthorizationFilter(application); final HttpServletRequest request = new MockHttpServletRequest(); final HttpServletResponse response = EasyMock.createMock(HttpServletResponse.class); final MockFilterChain filterChain = new MockFilterChain(); application.setConfigured(true);/* w ww.j a v a2 s. co m*/ application.setEditableConfig(false); response.sendRedirect("/repos/list"); EasyMock.replay(response); filter.doFilterInternal(request, response, filterChain); EasyMock.verify(response); assertNull(filterChain.getRequest()); assertNull(filterChain.getResponse()); }
From source file:com.netsteadfast.greenstep.sys.GreenStepBaseFormAuthenticationFilter.java
@Override protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request, ServletResponse response) throws Exception { HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; if (!this.isAjaxRequest(httpServletRequest)) { httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + this.getSuccessUrl()); } else {//ww w .j a v a2 s .co m response.setCharacterEncoding("UTF-8"); response.setContentType("application/json"); response.getWriter().write(Constants.NO_AUTHZ_JSON_DATA); } return false; }
From source file:com.netsteadfast.greenstep.sys.GreenStepMobileFormAuthenticationFilter.java
@Override protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request, ServletResponse response) throws Exception { HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; if (!this.isAjaxRequest(httpServletRequest)) { httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + this.getSuccessUrl()); } else {//ww w. j a v a2 s. co m response.setCharacterEncoding(Constants.BASE_ENCODING); response.setContentType("application/json"); response.getWriter().write(Constants.NO_AUTHZ_JSON_DATA); } return false; }
From source file:pivotal.au.se.gemfirexdweb.controller.ConmapController.java
@RequestMapping(value = "/viewconmap", method = RequestMethod.GET) public String worksheet(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 {/* w ww .j a v a2 s. co 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 show connection map"); ConnectionManager cm = ConnectionManager.getInstance(); String conMapAction = request.getParameter("conMapAction"); String key = request.getParameter("key"); logger.debug("conMapAction = " + conMapAction); logger.debug("key = " + key); if (conMapAction != null) { if (conMapAction.equalsIgnoreCase("DELETE")) { // remove this connection from Map and close it. cm.removeConnection(key); logger.debug("Connection closed for key " + key); model.addAttribute("saved", "Successfully closed connection with key " + key); } } model.addAttribute("conmap", cm.getConnectionMap()); model.addAttribute("conmapsize", cm.getConnectionListSize()); // This will resolve to /WEB-INF/jsp/conmap.jsp return "conmap"; }
From source file:info.magnolia.cms.taglibs.util.SimpleMailTag.java
/** * @see javax.servlet.jsp.tagext.TagSupport#doEndTag() */// w ww .j av a2s . c om public int doEndTag() throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); StringBuffer body = new StringBuffer(); // build and send email Content activePage = Resource.getActivePage(request); Iterator it; try { it = activePage.getContent(nodeCollectionName).getChildren().iterator(); } catch (RepositoryException e) { throw new NestableRuntimeException(e); } while (it.hasNext()) { Content node = (Content) it.next(); if (request.getParameterValues("field_" + node.getName()) != null) { String[] values = request.getParameterValues("field_" + node.getName()); body.append(node.getNodeData("title").getString() + "\n"); for (int i = 0; i < values.length; i++) { body.append(values[i] + "\n"); } body.append("\n"); } } String mailType = type; if (mailType == null) { mailType = MailConstants.MAIL_TEMPLATE_TEXT; } MgnlEmail email; try { email = MgnlMailFactory.getInstance().getEmailFromType(mailType); email.setToList(to); email.setCcList(cc); email.setBccList(bcc); email.setFrom(from); email.setSubject(subject); email.setBody(body.toString(), null); MgnlMailFactory.getInstance().getEmailHandler().prepareAndSendMail(email); } catch (Exception e) { // you may want to warn the user redirecting him to a different page... log.error(e.getMessage(), e); } if (StringUtils.isNotEmpty(redirect)) { HttpServletResponse response = (HttpServletResponse) pageContext.getResponse(); try { response.sendRedirect(request.getContextPath() + redirect); } catch (IOException e) { // should never happen log.error(e.getMessage(), e); } } return super.doEndTag(); }
From source file:com.liusoft.dlog4j.upload.SecurityFCKUploadServlet.java
/** * ?WAP//w w w. jav a 2s . c o m */ protected void makeOutput(HttpServletRequest req, HttpServletResponse res, Hashtable params, String msg) throws IOException { String toPage = (String) params.get("toPage"); if (StringUtils.isEmpty(toPage)) { super.makeOutput(req, res, params, msg); } else { res.sendRedirect(req.getContextPath() + toPage); } }
From source file:org.shredzone.cilla.view.AbstractView.java
/** * Redirect to the section's page main view when the page is restricted and has not * been unlocked yet. If a view of a locked page has been invoked, the visitor will be * redirected to the page where the unlock question is asked. * * @param page/* w w w . j a v a 2 s. c o m*/ * {@link Page} that is to be shown * @param req * {@link HttpServletRequest} * @param resp * {@link HttpServletResponse} * @return if {@code true}, the page access is restricted and must not be shown to the * user. A redirection to the main page has already been placed. */ protected boolean redirectRestricted(Page page, HttpServletRequest req, HttpServletResponse resp) throws ViewException { if (page.isRestricted() && !unlockService.isUnlocked(req.getSession(), page)) { try { resp.sendRedirect(linkService.linkTo().page(page).toString()); return true; } catch (IOException ex) { throw new ViewException(ex); } } return false; }
From source file:net.duckling.ddl.web.controller.LynxHomeController.java
@RequestMapping(params = "func=getMobile") public void getMobile(HttpServletRequest request, HttpServletResponse response) throws IOException { String u = request.getHeader("user-agent"); u = u.toLowerCase();// ww w . ja v a2s .co m LOGGER.info("???" + u); if (StringUtils.isEmpty(u)) { response.sendRedirect("/"); } else if (u.contains("ios") || u.contains("iphone") || u.contains("ipad")) { response.sendRedirect("http://itunes.apple.com/cn/app/ke-yan-zai-xian/id495109931"); } else if (u.contains("android")) { response.sendRedirect("http://www.escience.cn/apks/ddl-latest.apk"); } else { response.sendRedirect("/"); } }
From source file:pivotal.au.se.gemfirexdweb.controller.PrefsController.java
@RequestMapping(value = "/preferences", method = RequestMethod.GET) public String showPreferences(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 {/*w ww. ja v a 2s . c om*/ 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 show preferences"); model.addAttribute("userPref", (UserPref) session.getAttribute("prefs")); // This will resolve to /WEB-INF/jsp/preferences.jsp return "preferences"; }