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:com.sundbybergsit.servlets.OAuth2CallbackServlet.java

@Override
protected void onSuccess(HttpServletRequest request, HttpServletResponse response, Credential credential)
        throws ServletException, IOException {
    response.sendRedirect("/");
    FatmanLoginBean loginBean = (FatmanLoginBean) request.getSession().getAttribute("loginBean");
    if (loginBean == null) {
        loginBean = new FatmanLoginBean();
        request.getSession().setAttribute("loginBean", loginBean);
    }/*from   ww w.j  av a  2  s .  com*/
    loginBean.setAccessToken(credential.getAccessToken());
    loginBean.setSessionId(request.getSession(true).getId());
    loginBean.setLoggedIn(true);
}

From source file:com.starr.smartbuilds.controller.AuthController.java

@RequestMapping(method = { RequestMethod.GET }, value = "/exit")
public void getExit(Model model, HttpServletRequest req, HttpServletResponse resp) throws IOException {
    HttpSession session = req.getSession();
    session.setAttribute("user", null);
    resp.sendRedirect("../");
}

From source file:userlogout.java

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    HttpSession session = request.getSession(true);
    session.invalidate();// w  w  w .ja v  a  2 s . co  m
    response.sendRedirect("userlogin.jsp");

}

From source file:org.shaf.server.security.RestAuthenticationEntryPoint.java

/**
 * Executes if authentication is required.
 */// www .  j  a  v  a  2 s  . c  om
@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException {
    LOG.debug("SECURITY: Authentication request...");

    response.sendRedirect(request.getContextPath() + "/login.jsp");
}

From source file:org.client.one.util.CustomLogoutSuccessHandler.java

@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication auth)
        throws IOException, ServletException {
    String redirectUrl = request.getContextPath() + "/core/logoutSuccess";
    response.sendRedirect(redirectUrl);
}

From source file:com.ibm.gbs.gbs_cai_web.config.AuthInterceptor.java

@Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse res, Object o) throws Exception {
    HttpSession session = req.getSession();

    if (session.getAttribute("user") == null) {
        res.sendRedirect("/login");
        return false;
    }/*from   w  ww.j a va  2  s.com*/

    return true;
}

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

private void accessForbidden(HttpServletRequest req, HttpServletResponse res) throws IOException {
    res.sendRedirect(URLManager.getApplicationURL() + "/admin/jsp/accessForbidden.jsp");
}

From source file:net.triptech.buildulator.RedirectAccessDeniedHandler.java

/**
 * Handle the access denied action.//from   w ww  .j a va 2  s. c  o m
 *
 * @param request the request
 * @param response the response
 * @param accessDeniedException the access denied exception
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws ServletException the servlet exception
 */
@Override
public final void handle(final HttpServletRequest request, final HttpServletResponse response,
        final AccessDeniedException accessDeniedException) throws IOException, ServletException {

    response.sendRedirect(this.accessDeniedUrl);
}

From source file:kr.steelheart.site.blog.web.FeedController.java

@RequestMapping(value = { "/rss", "/tc/rss" }, method = RequestMethod.GET)
public void rss(final HttpServletResponse response) throws IOException {
    response.sendRedirect("/feed");
}

From source file:org.test.skeleton.controller.ExpliotDemoController.java

@RequestMapping(value = "/csrf/messages/", method = RequestMethod.POST)
public void exploit(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Message messageToSave = messageParser.parse(request.getInputStream());

    messageDao.save(messageToSave);//from   w w  w.  ja v  a  2  s .  c om

    response.sendRedirect(request.getContextPath());
}