Example usage for javax.servlet.http HttpServletResponse sendRedirect

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

Introduction

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

Prototype

public void sendRedirect(String location) throws IOException;

Source Link

Document

Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer.

Usage

From source file:azkaban.web.JobManagerServlet.java

private void setMessagedUrl(HttpServletResponse response, String redirectUrl, String message)
        throws IOException {
    String url = redirectUrl + "/" + message;
    response.sendRedirect(response.encodeRedirectURL(url));
}

From source file:com.meetme.plugins.jira.gerrit.adminui.AdminServlet.java

private void redirectToLogin(final HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    response.sendRedirect(loginUriProvider.getLoginUri(getUri(request)).toASCIIString());
}

From source file:Controller.AdminController.java

@RequestMapping(value = "ProsesHapusAdmin.htm", method = RequestMethod.GET)
public void ProsesHapusAdmin(HttpServletResponse response, @RequestParam(value = "id", required = false) int id)
        throws IOException {
    AdminImplement ai = new AdminImplement();
    Admin a = ai.getByID(id);/*from  w  ww .  ja  va 2 s . c  om*/
    ai.delete(a);
    response.sendRedirect("TampilAllAdmin.htm");
}

From source file:com.ikon.servlet.PasswordResetServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    ServletContext sc = getServletContext();
    sc.removeAttribute("forgot");
    sc.removeAttribute("failed");
    response.sendRedirect("login.jsp");
}

From source file:com.silverpeas.peasUtil.GoTo.java

private void objectNotFound(HttpServletRequest req, HttpServletResponse res) throws IOException {
    boolean isLoggedIn = isUserLogin(req);
    if (!isLoggedIn) {
        res.sendRedirect("/weblib/notFound.html");
    } else {/*from   w ww  .  j  a va2  s .c  o  m*/
        res.sendRedirect(URLManager.getApplicationURL() + "/admin/jsp/documentNotFound.jsp");
    }
}

From source file:feedme.controller.LogoutServlet.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request//from  w w  w.  j av  a2  s.  co m
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    processRequest(request, response);

    request.getSession().removeAttribute("AuthenticatUser");//remove session
    response.sendRedirect(request.getContextPath() + "/");//return to the main page
    return;

}

From source file:com.smile.pentaho.birtplugin.BIRTContentGenerator.java

public void createContent() throws Exception {
    this.session = PentahoSessionHolder.getSession();
    this.repository = PentahoSystem.get(IUnifiedRepository.class, session);

    RepositoryFile BIRTfile = (RepositoryFile) parameterProviders.get("path").getParameter("file");
    String ExecBIRTFilePath = "../../pentaho-solutions/" + BIRTfile.getId() + ".rptdesign";
    /*// ww w.  j a  va  2s  .  c o m
     * Get BIRT report design from repository       
     */
    File ExecBIRTFile = new File(ExecBIRTFilePath);
    if (!ExecBIRTFile.exists()) {
        Writer writer = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(ExecBIRTFilePath), "UTF-8"));
        try {
            SimpleRepositoryFileData data = repository.getDataForRead(BIRTfile.getId(),
                    SimpleRepositoryFileData.class);
            Reader reader = new InputStreamReader(data.getInputStream(), "UTF8");
            int c;
            while ((c = reader.read()) != -1) {
                writer.write(c);
            }
        } catch (Exception e) {
            Logger.error(getClass().getName(), e.getMessage());
        } finally {
            writer.close();
        }
    }
    /*
     * Redirect to BIRT Viewer
     */
    try {
        //Get informations about user context
        IUserRoleListService service = PentahoSystem.get(IUserRoleListService.class);
        String roles = "";
        ListIterator li = service.getRolesForUser(null, session.getName()).listIterator();
        while (li.hasNext()) {
            roles = roles + li.next().toString() + ",";
        }

        //Redirect
        HttpServletResponse response = (HttpServletResponse) this.parameterProviders.get("path")
                .getParameter("httpresponse");
        response.sendRedirect("/WebViewerExample/frameset?__report=" + BIRTfile.getId()
                + ".rptdesign&__showtitle=false&username=" + session.getName() + "&userroles=" + roles
                + "&reportname=" + BIRTfile.getTitle());
    } catch (Exception e) {
        Logger.error(getClass().getName(), e.getMessage());
    }
}

From source file:com.innoventsolutions.pentaho.birtrptdocplugin.BIRTContentGenerator.java

@Override
public void createContent() throws Exception {
    this.session = PentahoSessionHolder.getSession();
    this.repository = PentahoSystem.get(IUnifiedRepository.class, session);
    final RepositoryFile BIRTfile = (RepositoryFile) parameterProviders.get("path").getParameter("file");
    final String ExecBIRTFilePath = "../webapps/birt/" + BIRTfile.getId() + ".rptdocument";
    /*/*from w w  w . j  a  va  2  s  . c  o m*/
     * Get BIRT report design from repository
     */
    final File ExecBIRTFile = new File(ExecBIRTFilePath);
    if (!ExecBIRTFile.exists()) {
        final FileOutputStream fos = new FileOutputStream(ExecBIRTFilePath);
        try {
            final SimpleRepositoryFileData data = repository.getDataForRead(BIRTfile.getId(),
                    SimpleRepositoryFileData.class);
            final InputStream inputStream = data.getInputStream();
            final byte[] buffer = new byte[0x1000];
            int bytesRead = inputStream.read(buffer);
            while (bytesRead >= 0) {
                fos.write(buffer, 0, bytesRead);
                bytesRead = inputStream.read(buffer);
            }
        } catch (final Exception e) {
            Logger.error(getClass().getName(), e.getMessage());
        } finally {
            fos.close();
        }
    }
    /*
     * Redirect to BIRT Viewer
     */
    try {
        // Get informations about user context
        final IUserRoleListService service = PentahoSystem.get(IUserRoleListService.class);
        String roles = "";
        final ListIterator<String> li = service.getRolesForUser(null, session.getName()).listIterator();
        while (li.hasNext()) {
            roles = roles + li.next().toString() + ",";
        }
        // Redirect
        final HttpServletResponse response = (HttpServletResponse) this.parameterProviders.get("path")
                .getParameter("httpresponse");
        response.sendRedirect(
                "/birt/frameset?__document=" + BIRTfile.getId() + ".rptdocument&__showtitle=false&username="
                        + session.getName() + "&userroles=" + roles + "&reportname=" + BIRTfile.getTitle());
    } catch (final Exception e) {
        Logger.error(getClass().getName(), e.getMessage());
    }
}

From source file:io.muic.ooc.servlet.LoginServlet.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    // do login post logic
    // extract username and password from request
    if (SecurityService.isAuthorized(request)) {
        response.sendRedirect("/home");
    } else {//from ww w . j av  a 2s .  c  om
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        if (!StringUtils.isBlank(username) && !StringUtils.isBlank(password)) {
            if (SecurityService.authenticate(username, password, request)) {
                response.sendRedirect("home");
            } else {
                String error = "Wrong username or password.";
                request.setAttribute("error", error);
                RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/login.jsp");
                rd.include(request, response);
            }
        } else {
            String error = "Username or password is missing.";
            request.setAttribute("error", error);
            RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/login.jsp");
            rd.include(request, response);
        }
    }

}

From source file:com.museum_web.controller.AnnotationController.java

@RequestMapping("/actions/SaveAnnotation")
public void saveAnnotation(Annotation annotation, HttpServletResponse response) throws Exception {

    if (annotation.getId() == 0) {
        annotation.setId(null);//from  w w w .  j av a2  s.co m
        as.createAnnotation(annotation);
    } else
        as.editAnnotation(annotation);

    response.sendRedirect("../annotation");

}