List of usage examples for javax.servlet.http HttpServletResponse sendRedirect
public void sendRedirect(String location) throws IOException;
From source file:cn.vlabs.umt.ui.servlet.ThirdPartyLoginServlet.java
/** * ???requestToken/*from w w w . ja v a 2s. com*/ * @param request * @param response * */ private void doWeiboRequestToken(HttpServletResponse response) throws ServletException, IOException { Oauth oauth = new Oauth(); try { String url = oauth.authorize("code", "", ""); response.sendRedirect(url); } catch (WeiboException e) { LOGGER.error(e.getMessage(), e); } }
From source file:com.zving.platform.SysInfo.java
public static void uploadDB(HttpServletRequest request, HttpServletResponse response) { try {/*w w w . jav a 2 s . c o m*/ DiskFileItemFactory fileFactory = new DiskFileItemFactory(); ServletFileUpload fu = new ServletFileUpload(fileFactory); List fileItems = fu.parseRequest(request); fu.setHeaderEncoding("UTF-8"); Iterator iter = fileItems.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (!(item.isFormField())) { String OldFileName = item.getName(); System.out.println("Upload DB FileName:" + OldFileName); long size = item.getSize(); if ((((OldFileName == null) || (OldFileName.equals("")))) && (size == 0L)) { continue; } OldFileName = OldFileName.substring(OldFileName.lastIndexOf("\\") + 1); String ext = OldFileName.substring(OldFileName.lastIndexOf(".")); if (!(ext.toLowerCase().equals(".dat"))) { response.sendRedirect("DBUpload.jsp?Error=?dat?"); return; } final String FileName = Config.getContextRealPath() + "WEB-INF/data/backup/DBUpload_" + DateUtil.getCurrentDate("yyyyMMddHHmmss") + ".dat"; item.write(new File(FileName)); LongTimeTask ltt = LongTimeTask.getInstanceByType("Install"); if (ltt != null) { response.sendRedirect("DBUpload.jsp?Error=??"); return; } SessionListener.forceExit(); Config.isAllowLogin = false; ltt = new LongTimeTask() { public void execute() { DBImport di = new DBImport(); di.setTask(this); di.importDB(FileName, "Default"); setPercent(100); Config.loadConfig(); CronManager.getInstance().init(); } }; ltt.setType("Install"); ltt.setUser(User.getCurrent()); ltt.start(); response.sendRedirect("DBUpload.jsp?TaskID=" + ltt.getTaskID()); } } } catch (Exception e) { e.printStackTrace(); } finally { Config.isAllowLogin = true; } }
From source file:com.fullmetalgalaxy.server.pm.PMServlet.java
@Override protected void doGet(HttpServletRequest p_req, HttpServletResponse p_resp) throws ServletException, IOException { EbAccount account = ServerUtil.findRequestedAccount(p_req); if (account == null) { p_resp.sendRedirect("/genericmsg.jsp?title=Le profil n'a pas t trouv."); return;/* w w w . ja v a 2 s.c om*/ } String subject = p_req.getParameter("subject"); p_resp.sendRedirect(account.getEMailUrl(subject)); }
From source file:pivotal.au.se.gemfirexdweb.controller.RefreshController.java
@RequestMapping(value = "/refresh", method = RequestMethod.GET) public String showTables(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 va 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 refresh schema object list"); Map schemaMap = (Map) session.getAttribute("schemaMap"); Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); // get schema count now schemaMap = QueryUtil.populateSchemaMap(conn, schemaMap, (String) session.getAttribute("schema")); session.setAttribute("schemaMap", schemaMap); // This will resolve to /WEB-INF/jsp/tables.jsp return "main"; }
From source file:com.starr.smartbuilds.controller.AddController.java
@RequestMapping(method = { RequestMethod.GET }) public String getBuilder(Model model, HttpServletRequest req, HttpServletResponse resp) throws IOException, ParseException { HttpSession session = req.getSession(); User user = (User) session.getAttribute("user"); if (user == null) { resp.sendRedirect("./"); } else {//from w w w .j a v a 2 s . c o m model.addAttribute("authMsg", "Hello," + user.getSummonerName() + "!"); model.addAttribute("exitReg", "<a href='./auth/exit'>Exit</a>"); model.addAttribute("createbuild", "<li><a href='./add' style='color: #deff00;'>Create Build</a></li>"); } Build build = new Build(); build.setName("Build name"); model.addAttribute("build", build); List<Category> categories = categoryDAO.listCategories(); model.addAttribute("categories", categories); List<Tag> tags = tagDAO.listTags(); model.addAttribute("tags", tags); List<Champion> champions = championDAO.listChampions(); model.addAttribute("champions", champions); return "add_build"; }
From source file:org.openmrs.module.cloneandexportomrs.web.controller.CloneandexportOpenMRSManageController.java
@RequestMapping(value = "/module/cloneandexportomrs/downloadDb", method = RequestMethod.POST) public void downloadDbPost(ModelMap model, HttpServletResponse response) { String clone = Context.getService(CloneAndExportOmrsService.class).downloadDbBackUp(); try {/*from w w w . j a va2 s . co m*/ exportZipFile(response, 4096, clone); response.sendRedirect("downloadDb.form"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.truthbean.demo.ssm.controller.UserSessionFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { Object object = request.getSession().getAttribute("user"); if (object != null && object instanceof User) { filterChain.doFilter(request, response); } else {/*from ww w .ja v a 2 s. c o m*/ response.sendRedirect(request.getContextPath() + "/login.html"); } }
From source file:grails.plugin.springsecurity.web.GrailsRedirectStrategy.java
public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url) throws IOException { String redirectUrl = calculateRedirectUrl(request, url); redirectUrl = response.encodeRedirectURL(redirectUrl); log.debug("Redirecting to '{}'", redirectUrl); response.sendRedirect(redirectUrl); }
From source file:org.chos.transaction.controller.MerchantManagerController.java
@RequestMapping(value = "/merchant/{id}/item") public String merchantItem(@PathVariable int id, HttpServletRequest request, HttpServletResponse response, Model model) throws IOException { Session session = httpContextSessionManager.getSession(request); if (session == null) { response.sendRedirect("login.shtml"); }// www.j a va 2 s. com List<Category> categories = itemService.getCategories(session.getUserId()); List<Product> products = productService.getByUserId(session.getUserId()); model.addAttribute("categories", categories); model.addAttribute("products", products); return "business/tmpl-merchant-item"; }
From source file:com.app.controller.interceptor.ActiveInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { User currentUser = UserUtil.getCurrentUser(); if (!currentUser.isActive()) { WebUtils.setSessionAttribute(request, "info", LanguageUtil.getMessage("resubscribe-for-access")); response.sendRedirect("my_account"); return false; }//from ww w . j a v a2 s .c o m return true; }