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:pivotal.au.se.gemfirexdweb.controller.JMXController.java

@RequestMapping(value = "/jmxmbeans", method = RequestMethod.GET)
public String showJMXMbeans(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  ww  w .ja  v  a  2  s .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;
            }
        }

    }

    UserPref userPref = (UserPref) session.getAttribute("prefs");
    String jolokiaURL = userPref.getJolokiaURL();

    String mbeanName = request.getParameter("mbeanName");

    if (mbeanName != null) {
        logger.debug("Received request to show Mbean Attributes");
        logger.debug("mbeanName = " + mbeanName);

        String refreshTime = request.getParameter("refreshTime");
        if (refreshTime == null) {
            refreshTime = "none";
        }

        logger.debug("refresh time : " + refreshTime);

        Map<String, Object> attributes = getMbeanAttributeValues(mbeanName, jolokiaURL);

        model.addAttribute("refreshTime", refreshTime);
        model.addAttribute("mbeanName", mbeanName);
        model.addAttribute("mbeanMap", attributes);
        model.addAttribute("records", attributes.size());

        // This will resolve to /WEB-INF/jsp/viewmbean.jsp
        return "viewmbean";
    } else {
        logger.debug("Received request to show JMX Mbeans for cluster");

        logger.debug("jolokiaURL = " + jolokiaURL);

        List<String> mbeanNames = searchMbeans("", jolokiaURL);

        model.addAttribute("mbeanNames", mbeanNames);
        model.addAttribute("records", mbeanNames.size());

        // This will resolve to /WEB-INF/jsp/showmbeans.jsp
        return "showmbeans";
    }

}

From source file:org.jamwiki.authentication.JAMWikiLogoutSuccessHandler.java

/**
 *
 *//*from w w  w.  ja va 2s  .co m*/
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    // Special:Logout adds a proper redirection URL as a parameter in the
    // Spring logout URL.
    String targetUrl = request
            .getParameter(JAMWikiAuthenticationConstants.SPRING_SECURITY_LOGOUT_REDIRECT_QUERY_PARAM);
    logger.info("Redirecting to: " + targetUrl);
    response.sendRedirect(targetUrl);
}

From source file:it.biztech.btable.BTableContentGenerator.java

@Override
public void createContent() throws Exception {
    IParameterProvider pathParams = parameterProviders.get(MethodParams.PATH);
    String filePath = pathParams.getStringParameter(MethodParams.PATH, "");

    HttpServletResponse response = (HttpServletResponse) pathParams.getParameter("httpresponse");

    String apiUrl = PentahoPluginEnvironment.getInstance().getUrlProvider().getPluginBaseUrl();
    String url = apiUrl + "render?btfile=" + filePath;

    if (response == null) {
        logger.error("response not found");
        return;/*from   w  w  w  . ja  va 2s.c  o  m*/
    }
    try {
        response.sendRedirect(url);
        response.getOutputStream().flush();
    } catch (IOException e) {
        logger.error("could not redirect", e);
    }
}

From source file:pivotal.au.se.gemfirexdweb.controller.CreateSynonymController.java

@RequestMapping(value = "/createsynonym", method = RequestMethod.GET)
public String createType(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 ww  w .j  a  v a2 s  .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 create a new synonym");

    TableDAO tableDAO = GemFireXDWebDAOFactory.getTableDAO();
    ViewDAO viewDAO = GemFireXDWebDAOFactory.getViewDAO();

    List<View> views = viewDAO.retrieveViewList((String) session.getAttribute("schema"), null,
            (String) session.getAttribute("user_key"));

    model.addAttribute("views", views);

    List<Table> tbls = tableDAO.retrieveTableList((String) session.getAttribute("schema"), null,
            (String) session.getAttribute("user_key"), "ORDINARY");

    List<Table> tblsHDFS = tableDAO.retrieveTableList((String) session.getAttribute("schema"), null,
            (String) session.getAttribute("user_key"), "HDFS");

    tbls.addAll(tblsHDFS);

    model.addAttribute("tables", tbls);

    model.addAttribute("synonymAttribute", new NewSynonym());
    model.addAttribute("objectName", request.getParameter("objectName"));

    // This will resolve to /WEB-INF/jsp/create-synonym.jsp
    return "create-synonym";
}

From source file:com.quartercode.femtoweb.impl.FemtoWebFilter.java

@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) req;
    HttpServletResponse response = (HttpServletResponse) res;

    // Retrieve the requested URI
    String uri = RequestUtils.getRequestUri(request);

    // If no specific action is specified (empty URI, e.g. "/"), redirect to the index URI (by default "/index")
    if (StringUtils.remove(uri, '/').isEmpty()) {
        response.sendRedirect(request.getContextPath() + context.getIndexUri());
        return;/*from   w  w w .ja va2  s.  c  o m*/
    }

    // If the static content is requested, directly forward to that static content
    if (uri.startsWith(context.getStaticAssetPath())) {
        LOGGER.trace("Allowing direct access to static content '{}'", uri);
        chain.doFilter(request, response);
        return;
    }

    // If the request is no special case, retrieve and execute the action responsible for the requested URI
    processAction(request, response, uri);
}

From source file:edu.vt.middleware.ldap.servlets.LogoutServlet.java

/**
 * Handle all requests sent to this servlet.
 *
 * @param  request  <code>HttpServletRequest</code>
 * @param  response  <code>HttpServletResponse</code>
 *
 * @throws  ServletException  if this request cannot be serviced
 * @throws  IOException  if a response cannot be sent
 *//*from   www . ja v  a 2  s .  c  o  m*/
public void service(final HttpServletRequest request, final HttpServletResponse response)
        throws ServletException, IOException {
    String url = request.getParameter(ServletConstants.URL_PARAM);
    if (url == null) {
        url = "";
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Received url param = " + url);
    }

    this.sessionManager.logout(request.getSession(true));
    response.sendRedirect(url);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Redirected user to " + url);
    }
}

From source file:pivotal.au.se.gemfirexdweb.controller.CreateTriggerController.java

@RequestMapping(value = "/createtrigger", method = RequestMethod.GET)
public String createTrigger(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  . j a  v a  2  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 create a new Trigger");

    NewTrigger newTrigger = new NewTrigger();

    if (request.getParameter("settablename") != null) {
        model.addAttribute("tableName", request.getParameter("settablename"));
    }

    model.addAttribute("triggerAttribute", newTrigger);

    TableDAO tableDAO = GemFireXDWebDAOFactory.getTableDAO();

    List<Table> tables = tableDAO.retrieveTableList((String) session.getAttribute("schema"), null,
            (String) session.getAttribute("user_key"), "tables");

    model.addAttribute("tables", tables);

    // This will resolve to /WEB-INF/jsp/create-trigger.jsp
    return "create-trigger";
}

From source file:pivotal.au.se.gemfirexdweb.controller.CreateAsyncController.java

@RequestMapping(value = "/createasync", method = RequestMethod.GET)
public String createAsync(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. j a  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 create a new Async Event Listener");

    DiskStoreDAO dsDAO = GemFireXDWebDAOFactory.getDiskStoreDAO();

    List<DiskStore> dsks = dsDAO.retrieveDiskStoreForCreateList((String) session.getAttribute("user_key"));

    model.addAttribute("diskstores", dsks);
    model.addAttribute("asyncAttribute", new NewAsync());

    // This will resolve to /WEB-INF/jsp/create-async.jsp
    return "create-async";
}

From source file:seava.j4e.web.controller.ui.extjs.UiExtjsMainController.java

@RequestMapping(value = "*", method = RequestMethod.GET)
protected ModelAndView home(HttpServletRequest request, HttpServletResponse response) throws Exception {

    try {//from w  w w . j a va  2s . c om
        ISessionUser su = (ISessionUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

        if (su.isSessionLocked()) {
            throw new BusinessException(ErrorCode.SEC_SESSION_LOCKED, "Session has been locked.");
        }
    } catch (Exception e) {
        response.sendRedirect(this.getSettings().get(Constants.PROP_LOGIN_PAGE));
        return null;
    }

    Map<String, Object> model = new HashMap<String, Object>();
    this._prepare(model, request, response);

    /* ========== extensions =========== */

    model.put("extensions", getExtensionFiles(IExtensions.UI_EXTJS_MAIN, uiExtjsSettings.getUrlCore()));

    model.put("extensionsContent", getExtensionContent(IExtensions.UI_EXTJS_MAIN));

    String logo = this.getSettings().getParam(SysParam.CORE_LOGO_URL_EXTJS.name());

    if (logo != null && !logo.equals("")) {
        model.put("logo", logo);
    }
    return new ModelAndView(this.viewName, model);
}