List of usage examples for javax.servlet.http HttpServletResponse sendRedirect
public void sendRedirect(String location) throws IOException;
From source file:pivotal.au.se.gemfirexdweb.controller.CreateTypeController.java
@RequestMapping(value = "/createtype", 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 www. j a v a 2 s. com*/ 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 UDT (Type)"); model.addAttribute("typeAttribute", new Type()); // This will resolve to /WEB-INF/jsp/create-type.jsp return "create-type"; }
From source file:com.qatickets.web.service.AuthAdminFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; UserProfile user = UserHelper.getUser(req); if (user == null || false == user.isAdmin()) { // redirect to login pages String loginUrl = Urls.LOGIN_VIEW + ".html"; log.debug("Force user login: " + loginUrl); resp.sendRedirect(loginUrl); return;//from w w w . j av a2s .co m } AuthFilter.loadUserObjects(req); chain.doFilter(request, response); }
From source file:org.chos.transaction.passport.controller.WeiboPassportController.java
@RequestMapping(value = "/weibo/login") public void login(HttpServletRequest request, HttpServletResponse response) throws IOException { String code = request.getParameter("code"); String state = request.getParameter("state"); OAuthSession session = sessionService.getSession(state); if (session == null) { response.sendRedirect("http://chos2009.eicp.net/login.shtml"); }//from w w w . j a va2 s.c o m if (state == null) { response.sendRedirect("http://chos2009.eicp.net/login.shtml"); } if (!state.equals(session.getState())) { response.sendRedirect("http://chos2009.eicp.net/login.shtml"); } Map<String, String> param = new HashMap<String, String>(); param.put("client_id", "1824142258"); param.put("client_secret", "34b3cd48fa1a9577c21b37dfccffd6f9"); param.put("grant_type", "authorization_code"); param.put("code", code); param.put("redirect_uri", "http://chos2009.eicp.net"); HttpTemplate template = new HttpTemplate(); String resp = null; try { resp = template.post("https://api.weibo.com/oauth2/access_token", param); } catch (HttpException e) { response.sendRedirect("http://chos2009.eicp.net/login.shtml"); } JSONObject json = JSONObject.fromObject(resp); String ak = json.getString("access_token"); param = new HashMap<String, String>(); param.put("access_token", ak); try { resp = template.post("https://api.weibo.com/oauth2/get_token_info", param); } catch (HttpException e) { response.sendRedirect("http://chos2009.eicp.net/login.shtml"); } json = JSONObject.fromObject(resp); String userId = json.getString("uid"); User user = userService.create(userId + "@weibo", null, "13120984792", "13120984792@weibo.com", true, request, response); response.sendRedirect("http://chos2009.eicp.net/mindex.htm"); }
From source file:it.govpay.web.console.pagamenti.mbean.EventiMBean.java
public String exportSelected() { try {/* w w w. j a v a2 s . c o m*/ // recupero lista diagnostici List<Long> idEventi = new ArrayList<Long>(); // se nn sono in select all allore prendo solo quelle selezionate if (!this.isSelectedAll()) { Iterator<EventoBean> it = this.selectedIds.keySet().iterator(); while (it.hasNext()) { EventoBean evtBean = it.next(); if (this.selectedIds.get(evtBean).booleanValue()) { idEventi.add(evtBean.getDTO().getId()); it.remove(); } } } // We must get first our context FacesContext context = FacesContext.getCurrentInstance(); // Then we have to get the Response where to write our file HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); response.sendRedirect(context.getExternalContext().getRequestContextPath() + "/eventiexporter?isAll=" + this.isSelectedAll() + "&ids=" + StringUtils.join(idEventi, ",") + "&formato=" + this.tipoExport); context.responseComplete(); // End of the method } catch (Exception e) { FacesContext.getCurrentInstance().responseComplete(); log.error(e, e); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Si e' verificato un errore durante l'esportazione degli eventi selezionati.", null)); } return null; }
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.Logout.java
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) { try {/*from w ww.j a va 2 s. c o m*/ String referrer = getReferringPage(request); String redirectUrl = LogoutRedirector.getRedirectUrl(request, response, referrer); Authenticator.getInstance(request).recordUserIsLoggedOut(); DisplayMessage.setMessage(request, I18n.bundle(request).text("logged_out")); response.sendRedirect(redirectUrl); } catch (Exception ex) { log.error(ex, ex); } }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateSchemaController.java
@RequestMapping(value = "/createschema", method = RequestMethod.GET) public String createSchema(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 {//www. j a v a 2s . com 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 Schema"); model.addAttribute("schemaAttribute", new NewSchema()); model.addAttribute("schemas", GemFireXDWebDAOUtil.getAllSchemas((String) session.getAttribute("user_key"))); // This will resolve to /WEB-INF/jsp/create-schema.jsp return "create-schema"; }
From source file:controllers.LoginController.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/* ww w. j a v a 2s. c o 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 { response.setContentType("text/html;charset=UTF-8"); User user = (User) request.getAttribute("user"); if (user != null) { // User has been already registered response.sendRedirect(request.getContextPath() + "/home"); } else { // Remove user's session HttpSession session = request.getSession(false); String error = null; if (session != null && (error = (String) session.getAttribute("error")) != null) { request.setAttribute("error", error); session.removeAttribute("error"); } RequestDispatcher rd = request.getRequestDispatcher("login.jsp"); rd.forward(request, response); } }
From source file:net.lightbody.bmp.proxy.jetty.servlet.AdminServlet.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String target = null;/* ww w . j a v a 2 s .co m*/ response.sendRedirect(request.getContextPath() + request.getServletPath() + "/" + Long.toString(System.currentTimeMillis(), 36) + (target != null ? ("#" + target) : "")); }
From source file:com.gs.config.ItemBasedLogoutSuccessHandler.java
@Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication a) throws IOException, ServletException { //Se enva a refrescar la ventana de todos los clientes para que cierre la sessin requestNodeJS.sendRequestWithUsernameAndMethod(a.getName(), "/session-close"); System.out.println("-----------------------------CERRANDO SESIN-----------------------------"); response.sendRedirect("login?out=1"); //request.getRequestDispatcher("login?out=1").forward(request, response); }
From source file:com.starr.smartbuilds.controller.AuthController.java
@RequestMapping(method = { RequestMethod.GET }) public String getAuth(Model model, HttpServletRequest req, HttpServletResponse resp) throws IOException { HttpSession session = req.getSession(); User user = (User) session.getAttribute("user"); if (user == null) { model.addAttribute("authMsg", "<a href='./auth'>Log in</a>"); model.addAttribute("exitReg", "<a href='./reg'>Register</a>"); } else {//from w w w . j a va 2 s . c o m resp.sendRedirect("./"); } model.addAttribute("auth", new AuthService()); return "authorization"; }