List of usage examples for javax.servlet.http HttpServletResponse sendRedirect
public void sendRedirect(String location) throws IOException;
From source file:org.emr.intercepter.RequestInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { System.out.println("START ****************************Inspecting***************************"); LoginBean loginBean = new LoginBean(); boolean result = true; if (!validateSession(request, response, loginBean)) { System.out.println("!!!!!! REQ !!!!! redirect to login.htm"); response.sendRedirect("login.htm"); return false; } else {//from ww w .j av a2 s . c o m loginBean = (LoginBean) request.getSession().getAttribute("loginBean"); } checkACL(loginBean, request); // if (!requestURI.contains("login")) { // if (!ApplicationUtil.checkAuthentication(request.getSession())) { // response.sendRedirect("login.htm"); // result = false; // } // } System.out.println("END ****************************Inspecting***************************"); return result; }
From source file:pivotal.au.se.gemfirexdweb.controller.ViewController.java
@RequestMapping(value = "/views", method = RequestMethod.GET) public String showTables(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { int startAtIndex = 0, endAtIndex = 0; String schema = null;//from ww w.j ava2s. c o m 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 { 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 show views"); ViewDAO viewDAO = GemFireXDWebDAOFactory.getViewDAO(); Result result = new Result(); String viewAction = request.getParameter("viewAction"); String selectedSchema = request.getParameter("selectedSchema"); logger.debug("selectedSchema = " + selectedSchema); if (selectedSchema != null) { schema = selectedSchema; } else { schema = (String) session.getAttribute("schema"); } logger.debug("schema = " + schema); if (viewAction != null) { logger.debug("viewAction = " + viewAction); result = null; result = viewDAO.simpleviewCommand(schema, (String) request.getParameter("viewName"), viewAction, (String) session.getAttribute("user_key")); model.addAttribute("result", result); } List<View> views = viewDAO.retrieveViewList(schema, null, (String) session.getAttribute("user_key")); model.addAttribute("records", views.size()); model.addAttribute("estimatedrecords", views.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (views.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("views", views); } else { if (request.getParameter("startAtIndex") != null) { startAtIndex = Integer.parseInt(request.getParameter("startAtIndex")); } if (request.getParameter("endAtIndex") != null) { endAtIndex = Integer.parseInt(request.getParameter("endAtIndex")); if (endAtIndex > views.size()) { endAtIndex = views.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = views.subList(startAtIndex, endAtIndex); model.addAttribute("views", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); model.addAttribute("schemas", GemFireXDWebDAOUtil.getAllSchemas((String) session.getAttribute("user_key"))); model.addAttribute("chosenSchema", schema); // This will resolve to /WEB-INF/jsp/views.jsp return "views"; }
From source file:pivotal.au.se.gemfirexdweb.controller.IndexController.java
@RequestMapping(value = "/indexes", method = RequestMethod.GET) public String showInexes(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { int startAtIndex = 0, endAtIndex = 0; String schema = null;// w w w .ja v a2 s .co m 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 { 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 show indexes"); IndexDAO indexDAO = GemFireXDWebDAOFactory.getIndexDAO(); Result result = new Result(); String idxAction = request.getParameter("idxAction"); String selectedSchema = request.getParameter("selectedSchema"); logger.debug("selectedSchema = " + selectedSchema); if (selectedSchema != null) { schema = selectedSchema; } else { schema = (String) session.getAttribute("schema"); } logger.debug("schema = " + schema); if (idxAction != null) { logger.debug("idxAction = " + idxAction); result = null; result = indexDAO.simpleindexCommand(schema, (String) request.getParameter("indexName"), idxAction, (String) session.getAttribute("user_key")); model.addAttribute("result", result); } List<Index> indexes = indexDAO.retrieveIndexList(schema, null, (String) session.getAttribute("user_key")); model.addAttribute("records", indexes.size()); model.addAttribute("estimatedrecords", indexes.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (indexes.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("indexes", indexes); } else { if (request.getParameter("startAtIndex") != null) { startAtIndex = Integer.parseInt(request.getParameter("startAtIndex")); } if (request.getParameter("endAtIndex") != null) { endAtIndex = Integer.parseInt(request.getParameter("endAtIndex")); if (endAtIndex > indexes.size()) { endAtIndex = indexes.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = indexes.subList(startAtIndex, endAtIndex); model.addAttribute("indexes", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); model.addAttribute("schemas", GemFireXDWebDAOUtil.getAllSchemas((String) session.getAttribute("user_key"))); model.addAttribute("chosenSchema", schema); // This will resolve to /WEB-INF/jsp/indexes.jsp return "indexes"; }
From source file:com.enonic.cms.web.main.UpgradeController.java
/** * Redirect to self./* w w w .ja v a 2s . com*/ */ private void redirectToSelf(HttpServletRequest req, HttpServletResponse res) throws Exception { String url = req.getRequestURL().toString(); int index = url.indexOf("?"); if (index > -1) { url = url.substring(0, index); } // change '/upgrade_db [GET]' to '/upgrade [POST]' index = url.lastIndexOf("/"); if (index > -1) { url = url.substring(0, index); } res.sendRedirect(url + "/upgrade"); }
From source file:com.aquest.emailmarketing.web.controllers.TrackingController.java
/** * Gets the tracking link./*w w w .j a v a 2 s .com*/ * * @param request the request * @param response the response * @param id the id * @return the tracking link * @throws IOException Signals that an I/O exception has occurred. */ @RequestMapping(value = "/tracking", method = RequestMethod.GET) public void getTrackingLink(HttpServletRequest request, HttpServletResponse response, @RequestParam("id") String id) throws IOException { Base64 base64 = new Base64(true); String decriptedText = new String(base64.decode(id.getBytes())); String unique_id = decriptedText.substring(decriptedText.indexOf("trackingId=") + 11); String url = decriptedText.substring(0, decriptedText.indexOf("trackingId=") - 1); System.out.println(url); response.sendRedirect(url); Timestamp curTimestamp = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()); EmailList emailList = emailListService.getEmailListById(unique_id); TrackingResponse trackingResponse = new TrackingResponse(); trackingResponse.setBroadcast_id(emailList.getBroadcast_id()); trackingResponse.setEmail(emailList.getEmail()); trackingResponse.setResponse_type("Click"); trackingResponse.setUnique_id(emailList.getId()); trackingResponse.setResponse_source("Internal Tracking"); trackingResponse.setResponse_url(url); trackingResponse.setResponse_time(curTimestamp); trackingResponse.setProcessed_dttm(curTimestamp); trackingResponseService.SaveOrUpdate(trackingResponse); }
From source file:com.museum_web.controller.ScenarioController.java
@RequestMapping("actions/editScenario") public void edit(Scenario scenario, HttpServletRequest request, HttpServletResponse response) throws Exception { sc = new ScenarioService().findById(scenario.getId()); sc.setTheme(new ThemeService().findById(Long.parseLong(request.getParameter("idTheme")))); ob = (ArrayList<MuseologicalObject>) sc.getObjects(); if (sc.getClass() == ScenarioChallenge.class) { ScenarioChallenge shc = new ScenarioChallenge(); shc = (ScenarioChallenge) sc;// w w w . ja va 2 s .c o m ch = (ArrayList<Challenge>) shc.getChallenges(); } response.sendRedirect("../scenario"); }
From source file:com.qcadoo.mes.cmmsMachineParts.controller.PlannedEventMultiUploadController.java
@RequestMapping(value = "/getAttachmentForPlannedEvent.html", method = RequestMethod.GET) public final void getAttachment(@RequestParam("id") final Long[] ids, HttpServletResponse response) { DataDefinition attachmentDD = dataDefinitionService.get(CmmsMachinePartsConstants.PLUGIN_IDENTIFIER, CmmsMachinePartsConstants.MODEL_PLANNED_EVENT_ATTACHMENT); Entity attachment = attachmentDD.get(ids[0]); InputStream is = fileService//from w ww. ja v a2s . com .getInputStream(attachment.getStringField(PlannedEventAttachmentFields.ATTACHMENT)); try { if (is == null) { response.sendRedirect("/error.html?code=404"); } response.setHeader("Content-disposition", "inline; filename=" + attachment.getStringField(PlannedEventAttachmentFields.NAME)); response.setContentType( fileService.getContentType(attachment.getStringField(PlannedEventAttachmentFields.ATTACHMENT))); int bytes = IOUtils.copy(is, response.getOutputStream()); response.setContentLength(bytes); response.flushBuffer(); } catch (IOException e) { logger.error("Unable to copy attachment file to response stream.", e); } }
From source file:Blog.servlets.ChangePassword.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w ww. ja v a 2 s . c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { Query q = new Query(); String pass = request.getParameter("pass");//actual String pass1 = request.getParameter("pass1");//nueva String user = "0"; if (q.Autentication(user, pass)) { q.EditPassword(pass1, user); response.sendRedirect("profile.jsp"); } else { response.sendRedirect("UpdatePassword.jsp"); } } }
From source file:cn.vlabs.umt.ui.actions.FindPasswordAction.java
/** * ?//from w ww.j ava 2s . c om * */ public ActionForward submitStepOne(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute("isStatic", "true"); ErrorMsgs msgs = new RemindPasswordFormValidator(request).validateForm(); if (!msgs.isPass()) { return mapping.findForward("find.password.stepOne"); } String loginEmail = request.getParameter("loginEmail"); User user = getUserService().getUserByLoginName(loginEmail); SessionUtils.setSessionVar(request, "findPswUserId", user.getId()); response.sendRedirect(RequestUtil.getContextPath(request) + "/findPsw.do?act=stepTwo"); return null; }
From source file:nl.surfnet.spring.security.opensaml.AuthenticationFailureHandlerImpl.java
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException authenticationException) throws IOException, ServletException { SavedRequest savedRequest = requestCache.getRequest(request, response); logger.debug("saved Request: {}", savedRequest); if (authenticationException instanceof IdentityProviderAuthenticationException && savedRequest != null) { logger.warn("Authn Failure reported by the IDP.", authenticationException); logger.debug("Retry original request of {}", savedRequest.getRedirectUrl()); response.sendRedirect(savedRequest.getRedirectUrl()); } else {//from www . j a v a2 s. com logger.warn("Unrecoverable authn failure. Sending to Forbidden", authenticationException); response.sendError(HttpServletResponse.SC_FORBIDDEN); } }