Example usage for javax.servlet.http HttpServletResponse encodeRedirectUrl

List of usage examples for javax.servlet.http HttpServletResponse encodeRedirectUrl

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse encodeRedirectUrl.

Prototype

@Deprecated
public String encodeRedirectUrl(String url);

Source Link

Usage

From source file:ar.com.zauber.commons.spring.servlet.view.PermanentlyRedirectView.java

/** @see RedirectView#sendRedirect() */
@Override/*from w  ww.j a  v  a 2  s  .c o m*/
protected final void sendRedirect(final HttpServletRequest request, final HttpServletResponse response,
        final String targetUrl, final boolean http10Compatible) throws IOException {

    if (request.getMethod().toLowerCase().equals("get")) {
        response.setStatus(301);
        response.setHeader("Location", response.encodeRedirectURL(targetUrl));
    } else {
        super.sendRedirect(request, response, targetUrl, http10Compatible);
    }
}

From source file:org.webcurator.ui.report.controller.ReportSaveController.java

@Override
protected ModelAndView processFormSubmission(HttpServletRequest req, HttpServletResponse resp, Object comm,
        BindException exc) throws Exception {

    ReportSaveCommand com = (ReportSaveCommand) comm;
    String format = com.getFormat();
    String action = com.getActionCmd();

    String dest = resp.encodeRedirectURL(req.getContextPath() + "/curator/report/report.html");

    if (action != null && action.equals(ACTION_SAVE)) {

        OperationalReport operationalReport = (OperationalReport) req.getSession()
                .getAttribute("operationalReport");
        operationalReport.getDownloadRendering(req, resp, "report", format, dest);

    } else if (action != null && action.equals(ACTION_CANCEL)) {

        resp.sendRedirect(dest);/*from  ww  w  . ja  va2 s. com*/

    } else {
        log.warn("action=[" + (action == null ? "null" : action) + "]");
    }
    return null;
}

From source file:br.com.flucianofeijao.security.JsfAccessDeniedHandler.java

public void handle(HttpServletRequest request, HttpServletResponse response,
        AccessDeniedException accessDeniedException) throws IOException, ServletException {
    String redirectUrl = calculateRedirectUrl(request.getContextPath(), loginPath);
    redirectUrl = response.encodeRedirectURL(redirectUrl);

    //we should redirect using ajax response if the case warrants
    boolean ajaxRedirect = request.getHeader("faces-request") != null
            && request.getHeader("faces-request").toLowerCase().indexOf("ajax") > -1;

    if (ajaxRedirect) {
        //javax.faces.context.FacesContext ctxt = javax.faces.context.FacesContext.getCurrentInstance();
        //ctxt.getExternalContext().redirect(redirectUrl);

        String ajaxRedirectXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                + "<partial-response><redirect url=\"" + redirectUrl + "\"></redirect></partial-response>";
        response.setContentType("text/xml");
        response.getWriter().write(ajaxRedirectXml);
    } else {//from www.  jav  a 2 s. com
        response.sendRedirect(redirectUrl);
    }
}

From source file:br.com.wavii.securyti.JsfAccessDeniedHandler.java

public void handle(HttpServletRequest request, HttpServletResponse response,
        AccessDeniedException accessDeniedException) throws IOException, ServletException {
    String redirectUrl = calculateRedirectUrl(request.getContextPath(), loginPath);
    redirectUrl = response.encodeRedirectURL(redirectUrl);

    // we should redirect using ajax response if the case warrants
    boolean ajaxRedirect = request.getHeader("faces-request") != null
            && request.getHeader("faces-request").toLowerCase().indexOf("ajax") > -1;

    if (ajaxRedirect) {
        // javax.faces.context.FacesContext ctxt =
        // javax.faces.context.FacesContext.getCurrentInstance();
        // ctxt.getExternalContext().redirect(redirectUrl);

        String ajaxRedirectXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                + "<partial-response><redirect url=\"" + redirectUrl + "\"></redirect></partial-response>";
        response.setContentType("text/xml");
        response.getWriter().write(ajaxRedirectXml);
    } else {/*from www.j  a  v a 2  s .  com*/
        response.sendRedirect(redirectUrl);
    }
}

From source file:br.com.gerenciapessoal.security.JsfAccessDeniedHandler.java

@Override
public void handle(HttpServletRequest request, HttpServletResponse response,
        AccessDeniedException accessDeniedException) throws IOException, ServletException {

    String redirectUrl = calculateRedirectUrl(request.getContextPath(), loginPath);
    redirectUrl = response.encodeRedirectURL(redirectUrl);

    //we should redirect using ajax response if the case warrants
    boolean ajaxRedirect = request.getHeader("faces-request") != null
            && request.getHeader("faces-request").toLowerCase().contains("ajax");

    if (ajaxRedirect) {
        //javax.faces.context.FacesContext ctxt = javax.faces.context.FacesContext.getCurrentInstance();
        //ctxt.getExternalContext().redirect(redirectUrl);

        String ajaxRedirectXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                + "<partial-response><redirect url=\"" + redirectUrl + "\"></redirect></partial-response>";
        response.setContentType("text/xml");
        response.getWriter().write(ajaxRedirectXml);
    } else {// w  w w.j a  v a  2 s. c  o m
        response.sendRedirect(redirectUrl);
    }
}

From source file:org.wallride.web.support.BlogLanguageRedirectStrategy.java

@Override
public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url)
        throws IOException {
    String redirectUrl = request.getContextPath() + url;

    BlogLanguageDataValueProcessor processor = new BlogLanguageDataValueProcessor();
    redirectUrl = processor.processUrl(request, redirectUrl);

    redirectUrl = response.encodeRedirectURL(redirectUrl);
    response.sendRedirect(redirectUrl);/*w w  w  .j a va2 s.c  o  m*/
}

From source file:org.etudes.mneme.tool.AssessmentExportView.java

/**
 * {@inheritDoc}//w  w w .  j av  a2 s. c om
 */
public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params)
        throws IOException {
    // read form
    String destination = this.uiService.decode(req, context);
    res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination)));
}

From source file:org.xine.marketplace.frontend.views.security.JsfAccessDeniedHandler.java

@Override
public void handle(final HttpServletRequest request, final HttpServletResponse response,
        final AccessDeniedException accessDeniedException) throws IOException, ServletException {
    String redirectUrl = calculateRedirectUrl(request.getContextPath(), this.loginPath);
    redirectUrl = response.encodeRedirectURL(redirectUrl);

    // we should redirect using ajax response if the case warrants
    final boolean ajaxRedirect = request.getHeader("faces-request") != null
            && request.getHeader("faces-request").toLowerCase().indexOf("ajax") > -1;

    if (ajaxRedirect) {
        // javax.faces.context.FacesContext ctxt =
        // javax.faces.context.FacesContext.getCurrentInstance();
        // ctxt.getExternalContext().redirect(redirectUrl);

        final String ajaxRedirectXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                + "<partial-response><redirect url=\"" + redirectUrl + "\"></redirect></partial-response>";
        response.setContentType("text/xml");
        response.getWriter().write(ajaxRedirectXml);
    } else {//from w ww  . j  a  va2  s .c  om
        response.sendRedirect(redirectUrl);
    }
}

From source file:org.etudes.mneme.tool.GradeQuestionsListView.java

/**
 * {@inheritDoc}//  w  ww.ja va 2  s.  c  o m
 */
public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params)
        throws IOException {
    // read form
    String destination = this.uiService.decode(req, context);

    // go to the destination
    res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination)));
}