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.CreateAsyncController.java
@RequestMapping(value = "/createasync", method = RequestMethod.POST) public String createAsyncAction(@ModelAttribute("asyncAttribute") NewAsync asyncAttribute, 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 av a 2 s. co 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 action an event for create Async Event Listener"); DiskStoreDAO dsDAO = GemFireXDWebDAOFactory.getDiskStoreDAO(); List<DiskStore> dsks = dsDAO.retrieveDiskStoreForCreateList((String) session.getAttribute("user_key")); model.addAttribute("diskstores", dsks); String asyncName = asyncAttribute.getAsyncName(); String listenerClass = asyncAttribute.getListenerClass(); logger.debug("New Async Event Listener Name = " + asyncName); logger.debug("New Async Event Listener Class = " + listenerClass); // perform some action here with what we have String submit = request.getParameter("pSubmit"); boolean needCloseBracket = false; if (submit != null) { // build create HDFS Store SQL StringBuffer createAsync = new StringBuffer(); createAsync.append("CREATE ASYNCEVENTLISTENER " + asyncName + " (\n"); createAsync.append("LISTENERCLASS '" + listenerClass + "' \n"); if (!checkIfParameterEmpty(request, "initParams")) { createAsync.append("INITPARAMS " + asyncAttribute.getInitParams() + " \n"); } else { createAsync.append("INITPARAMS '' \n"); } if (!checkIfParameterEmpty(request, "manualStart")) { createAsync.append("MANUALSTART " + asyncAttribute.getManualStart() + " \n"); } if (!checkIfParameterEmpty(request, "enableBatchConflation")) { createAsync.append("ENABLEBATCHCONFLATION " + asyncAttribute.getEnableBatchConflation() + " \n"); } if (!checkIfParameterEmpty(request, "batchSize")) { createAsync.append("BATCHSIZE " + asyncAttribute.getBatchSize() + " \n"); } if (!checkIfParameterEmpty(request, "batchTimeInterval")) { createAsync.append("BATCHTIMEINTERVAL " + asyncAttribute.getBatchTimeInterval() + " \n"); } if (!checkIfParameterEmpty(request, "enablePersistence")) { createAsync.append("ENABLEPERSISTENCE " + asyncAttribute.getEnablePersistence() + " \n"); if (asyncAttribute.getEnablePersistence().equals("TRUE")) { if (!checkIfParameterEmpty(request, "diskStore")) { createAsync.append("DISKSTORENAME " + asyncAttribute.getDiskStore() + " \n"); } } } if (!checkIfParameterEmpty(request, "maxQueueMemory")) { createAsync.append("MAXQUEUEMEMORY " + asyncAttribute.getMaxQueueMemory() + " \n"); } if (!checkIfParameterEmpty(request, "alertThreshold")) { createAsync.append("ALERTTHRESHOLD " + asyncAttribute.getAlertThreshold() + " \n"); } createAsync.append(") \n"); if (!checkIfParameterEmpty(request, "serverGroups")) { createAsync.append("SERVER GROUPS (" + asyncAttribute.getServerGroups() + ") \n"); } if (submit.equalsIgnoreCase("create")) { Result result = new Result(); logger.debug("Creating async event listener as -> " + createAsync.toString()); result = GemFireXDWebDAOUtil.runCommand(createAsync.toString(), (String) session.getAttribute("user_key")); model.addAttribute("result", result); } else if (submit.equalsIgnoreCase("Show SQL")) { logger.debug("Create Async SQL as follows as -> " + createAsync.toString()); model.addAttribute("sql", createAsync.toString()); } else if (submit.equalsIgnoreCase("Save to File")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, asyncName)); ServletOutputStream out = response.getOutputStream(); out.println(createAsync.toString()); out.close(); return null; } } // This will resolve to /WEB-INF/jsp/create-async.jsp return "create-async"; }
From source file:duoc.cl.dej4501.DejMobile.Presentacion.ValidaUsuarioServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession sesion = request.getSession(); String rut = request.getParameter("txtRut"); String clave = DigestUtils.md5Hex(request.getParameter("txtClave")); ClienteComunasDTO infoClienteComunasDTO = this.objClienteSessionBeans.ClienteValidaLogin(rut, clave); if (infoClienteComunasDTO != null) { sesion.setAttribute("usuarioConectado", infoClienteComunasDTO); response.sendRedirect("Menu.jsp"); } else {//from w w w.j a va 2 s . c o m sesion.setAttribute("msgError", "Usuario y/o Clave incorrecta"); response.sendRedirect("Login.jsp"); } }
From source file:it.smartcommunitylab.carpooling.controllers.UserAuthController.java
/** * This is a callback for the external AAC OAuth2.0 authentication. * Exchanges code for token, recover the profile and creates the user. * * @param request/*from www . j av a 2s .c o m*/ * @param response * @throws AACException * @throws SecurityException * @throws IOException */ @RequestMapping("/ext_callback") public void callback(HttpServletRequest request, HttpServletResponse response) { try { TokenData tokenData = service.exchngeCodeForToken(request.getParameter("code"), env.getProperty("ext.redirect")); BasicProfile basicProfile = processTokenData(request, response, tokenData); response.sendRedirect( "userloginsuccess?profile=" + URLEncoder.encode(JsonUtils.toJSON(basicProfile), "UTF-8")); } catch (Exception e) { try { response.sendRedirect("userloginerror?error=" + e.getMessage()); } catch (IOException e1) { e1.printStackTrace(); } } }
From source file:com.parallax.server.blocklyprop.servlets.AuthenticationServlet.java
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); String username = req.getParameter("username"); String password = req.getParameter("password"); User user = authenticationService.authenticate(username, password); if (user != null) { SavedRequest savedRequest = WebUtils.getAndClearSavedRequest(req); if (savedRequest != null) { resp.sendRedirect(savedRequest.getRequestUrl()); } else {/*from w w w .jav a 2s. co m*/ JsonObject response = new JsonObject(); response.addProperty("success", true); JsonObject userJson = new JsonObject(); userJson.addProperty("id-user", user.getId()); userJson.addProperty("screenname", user.getScreenname()); userJson.addProperty("email", user.getEmail()); response.add("user", userJson); resp.getWriter().write(response.toString()); } } else { JsonObject response = new JsonObject(); response.addProperty("success", false); response.addProperty("message", "Invalid authentication"); resp.getWriter().write(response.toString()); } }
From source file:com.netspective.sparx.value.BasicDbHttpServletValueContext.java
public void sendRedirect(String url) throws IOException { HttpServletResponse resp = (HttpServletResponse) response; resp.sendRedirect(resp.encodeRedirectURL(url)); redirected = true;//w ww . j a va 2s . com }
From source file:pivotal.au.se.gemfirexdweb.controller.DiskStoreController.java
@RequestMapping(value = "/diskstores", method = RequestMethod.GET) public String showDiskstores(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() + "/gemfirexdweb/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 show diskstores"); int startAtIndex = 0, endAtIndex = 0; javax.servlet.jsp.jstl.sql.Result allDiskStoreInfoResult = null; String schema = null; DiskStoreDAO dsDAO = GemFireXDWebDAOFactory.getDiskStoreDAO(); Result result = new Result(); String dsAction = request.getParameter("dsAction"); if (dsAction != null) { logger.debug("dsAction = " + dsAction); if (dsAction.equals("ALLDISKSTOREINFO")) { allDiskStoreInfoResult = dsDAO.getDiskstoreInfo((String) request.getParameter("dsName"), (String) session.getAttribute("user_key")); model.addAttribute("allDiskStoreInfoResult", allDiskStoreInfoResult); model.addAttribute("dsName", (String) request.getParameter("dsName")); } else { result = null; result = dsDAO.simplediskStoreCommand((String) request.getParameter("dsName"), dsAction, (String) session.getAttribute("user_key")); model.addAttribute("result", result); } } List<DiskStore> dsks = dsDAO.retrieveDiskStoreList("", null, (String) session.getAttribute("user_key")); model.addAttribute("records", dsks.size()); model.addAttribute("estimatedrecords", dsks.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (dsks.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("diskstores", dsks); } 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 > dsks.size()) { endAtIndex = dsks.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = dsks.subList(startAtIndex, endAtIndex); model.addAttribute("diskstores", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); // This will resolve to /WEB-INF/jsp/diskstores.jsp return "diskstores"; }
From source file:pivotal.au.se.gemfirexdweb.controller.HdfsStoreController.java
@RequestMapping(value = "/hdfsstores", method = RequestMethod.GET) public String showHdfsstores(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 {// w w w . j a v a2s . 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 show hdfs stores"); int startAtIndex = 0, endAtIndex = 0; javax.servlet.jsp.jstl.sql.Result allHdfsStoreInfoResult = null; String schema = null; HdfsStoreDAO hdfsDAO = GemFireXDWebDAOFactory.getHdfsStoreDAO(); Result result = new Result(); String hdfsAction = request.getParameter("hdfsAction"); if (hdfsAction != null) { logger.debug("hdfsAction = " + hdfsAction); if (hdfsAction.equals("ALLHDFSSTOREINFO")) { allHdfsStoreInfoResult = hdfsDAO.getHdfsStoreInfo((String) request.getParameter("hdfsName"), (String) session.getAttribute("user_key")); model.addAttribute("allHdfsStoreInfoResult", allHdfsStoreInfoResult); model.addAttribute("hdfsName", (String) request.getParameter("hdfsName")); } else { result = null; result = hdfsDAO.simplehdfsStoreCommand((String) request.getParameter("hdfsName"), hdfsAction, (String) session.getAttribute("user_key")); model.addAttribute("result", result); } } List<HdfsStore> hdfsStores = hdfsDAO.retrieveHdfsStoreList("", null, (String) session.getAttribute("user_key")); model.addAttribute("records", hdfsStores.size()); model.addAttribute("estimatedrecords", hdfsStores.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (hdfsStores.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("hdfsstores", hdfsStores); } 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 > hdfsStores.size()) { endAtIndex = hdfsStores.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = hdfsStores.subList(startAtIndex, endAtIndex); model.addAttribute("hdfsstores", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); // This will resolve to /WEB-INF/jsp/hdfsstores.jsp return "hdfsstores"; }
From source file:com.swiftcorp.portal.common.login.web.LoginAction.java
public ActionForward promptLogin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { theLogger.info("promptLogin()::"); HttpSession session = request.getSession(); if (session != null && session.getAttribute(SESSION_KEYS.LOGIN_INFO) != null) { response.sendRedirect(loginUserHomeRequestString); }// w ww . ja va2s. com String isSessionExpire = request.getParameter(SESSION_KEYS.IS_SESSION_EXPIRE); if ("true".equals(isSessionExpire)) { ActionErrors errors = new ActionErrors(); ActionMessage actionMessage = new ActionMessage("common.login.session.expire.msg"); errors.add(ActionMessages.GLOBAL_MESSAGE, actionMessage); request.setAttribute(Globals.ERROR_KEY, errors); } return mapping.findForward(ForwardNames.PROMT_LOGIN); }
From source file:br.com.hslife.orcamento.security.StartupUserParametersHandler.java
@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { try {/* www. j ava2 s. c om*/ // Carrega as opes do sistema do usurio autenticado getOpcaoSistemaComponent().atualizarCacheOpcoesSistema(); } catch (ApplicationException be) { logger.catching(be); } catch (Exception e) { logger.catching(e); } // Vai para o dashboard do sistema response.sendRedirect(request.getContextPath() + "/pages/menu/dashboard.faces"); }
From source file:com.kixeye.chassis.transport.swagger.SwaggerServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // figure out the real path String pathInfo = StringUtils.trimToEmpty(req.getPathInfo()); while (pathInfo.endsWith("/")) { pathInfo = StringUtils.removeEnd(pathInfo, "/"); }/*from w ww . j a v a 2s . c om*/ while (pathInfo.startsWith("/")) { pathInfo = StringUtils.removeStart(pathInfo, "/"); } if (StringUtils.isBlank(pathInfo)) { resp.sendRedirect(rootContextPath + "/" + WELCOME_PAGE); } else { // get the resource AbstractFileResolvingResource resource = (AbstractFileResolvingResource) resourceLoader .getResource(SWAGGER_DIRECTORY + "/" + pathInfo); // send it to the response if (resource.exists()) { StreamUtils.copy(resource.getInputStream(), resp.getOutputStream()); resp.setStatus(HttpServletResponse.SC_OK); resp.flushBuffer(); } else { resp.sendError(HttpServletResponse.SC_NOT_FOUND); } } }