List of usage examples for javax.servlet.http HttpServletResponse sendRedirect
public void sendRedirect(String location) throws IOException;
From source file:uk.ac.ebi.intact.editor.controller.curate.interaction.InteractionRemoteController.java
public void loadData(ComponentSystemEvent event) { interactions = getInteractionRemoteService().loadInteractions(proteins, pubRef); // redirect if one found if (interactions.size() == 1) { try {/*from w ww . j a v a2 s .c o m*/ HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance() .getExternalContext().getRequest(); HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance() .getExternalContext().getResponse(); response.sendRedirect( request.getContextPath() + "/interaction/" + interactions.iterator().next().getAc()); FacesContext.getCurrentInstance().responseComplete(); } catch (IOException e) { handleException(e); } } else if (interactions.size() == 0) { publication = getInteractionRemoteService().loadPublication(pubRef); if (publication != null) { experimentSelectItems = new ArrayList<SelectItem>(); experimentSelectItems.add(new SelectItem(null, "-- Select experiment --", null, false, true, true)); for (Experiment exp : publication.getExperiments()) { experimentSelectItems.add(new SelectItem(exp, interactionController.completeExperimentLabel((IntactExperiment) exp))); } } } }
From source file:com.galeoconsulting.leonardinius.servlet.ScriptRunnerSessionServlet.java
private boolean loginIfNot(HttpServletRequest request, HttpServletResponse response) throws ServletException { if (userManager.getRemoteUsername(request) == null) { try {//from ww w.j av a 2s. c o m URI currentUri = new URI(request.getRequestURI()); URI loginUri = loginUriProvider.getLoginUri(currentUri); response.sendRedirect(loginUri.toASCIIString()); } catch (URISyntaxException e) { throw new ServletException(e); } catch (IOException e) { throw new ServletException(e); } return true; } return false; }
From source file:net.duckling.ddl.service.authenticate.impl.AuthenticationServiceImpl.java
public void escienceRedirect(HttpServletRequest request, HttpServletResponse response) { String redirect = provider.makeUmtRegistUrl(request, VWBContainerImpl.findContainer().getURL("switchTeam", null, null, true)); try {// w w w . ja v a2s.co m response.sendRedirect(redirect); } catch (IOException e) { } }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateHDFSStoreController.java
@RequestMapping(value = "/createhdfsstore", method = RequestMethod.GET) public String createHDFSStore(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 va2 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 create a new HDFS Store"); model.addAttribute("hdfsStoreAttribute", new NewHDFSStore()); // This will resolve to /WEB-INF/jsp/create-hdfsstore.jsp return "create-hdfsstore"; }
From source file:com.trailmagic.image.ui.LogoutController.java
@RequestMapping("/logout") public void handleRequestInternal(HttpServletRequest req, HttpServletResponse res) throws Exception { SavedRequest savedRequest = requestCache.getRequest(req, res); HttpSession session = req.getSession(false); session.invalidate();//from w w w . j av a2s.c om Cookie terminate = new Cookie(TokenBasedRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, null); terminate.setMaxAge(0); res.addCookie(terminate); if (savedRequest != null) { res.sendRedirect(savedRequest.getRedirectUrl()); } else { res.sendRedirect("/photo/albums/"); } }
From source file:com.museum_web.controller.ChallengeController.java
@RequestMapping("actions/removeAnswer/{Answer}") public void removeAnswer(@PathVariable("Answer") Long answer, HttpServletRequest request, HttpServletResponse response) throws Exception { List<Answer> aux = c.getAnswers(); for (Answer x : aux) { if (x.getId().compareTo(answer) == 0) { aux.remove(x);//from w w w.j ava2 s . c o m break; } } c.setAnswers(aux); new ChallengeService().editChallenge(c); response.sendRedirect("../../challengeCreate?id=" + c.getChallengeId()); }
From source file:pivotal.au.se.gemfirexdweb.controller.JarController.java
@RequestMapping(value = "/jars", method = RequestMethod.POST) public String performJarAction(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; } } } int startAtIndex = 0, endAtIndex = 0; Result result = new Result(); List<Jar> jars = null; logger.debug("Received request to perform an action on the jar list"); JarDAO jarDAO = GemFireXDWebDAOFactory.getJarStoreDAO(); if (request.getParameter("search") != null) { jars = jarDAO.retrieveJarList("", (String) request.getParameter("search"), (String) session.getAttribute("user_key")); model.addAttribute("search", (String) request.getParameter("search")); } model.addAttribute("records", jars.size()); model.addAttribute("estimatedrecords", jars.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (jars.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("jars", jars); } 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 > jars.size()) { endAtIndex = jars.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = jars.subList(startAtIndex, endAtIndex); model.addAttribute("jars", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); // This will resolve to /WEB-INF/jsp/jars.jsp return "jars"; }
From source file:gsn.http.ac.MyDataSourceCandidateWaitingListServlet.java
private void redirectToLogin(HttpServletRequest req, HttpServletResponse res) throws IOException { req.getSession().setAttribute("login.target", HttpUtils.getRequestURL(req).toString()); res.sendRedirect("/gsn/MyLoginHandlerServlet"); }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateGatewaySenderController.java
@RequestMapping(value = "/creategatewaysender", method = RequestMethod.GET) public String createGatewaySender(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 . ja 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 create a new Gateway Sender"); DiskStoreDAO dsDAO = GemFireXDWebDAOFactory.getDiskStoreDAO(); List<DiskStore> dsks = dsDAO.retrieveDiskStoreForCreateList((String) session.getAttribute("user_key")); model.addAttribute("diskstores", dsks); model.addAttribute("gatewaySenderAttribute", new NewGatewaySender()); // This will resolve to /WEB-INF/jsp/create-gatewaysender.jsp return "create-gatewaysender"; }
From source file:com.oic.net.Callback.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); String code = request.getParameter("code"); if (request.getParameter("code") == null) { //OAuth??code???? response.sendRedirect("/"); } else if (request.getParameter("register") != null) { //ID? session.setAttribute("alreadyId", true); return;//from ww w. ja v a 2 s . co m } if (session.isNew()) { session.setMaxInactiveInterval(300); } String email = ""; try { getToken(code); System.out.println(code); email = getEmailAddress(); } catch (Exception e) { e.printStackTrace(); } Pattern pattern = Pattern.compile("@oic.jp$"); Matcher matcher = pattern.matcher(email); if (matcher.find()) { Pattern numberPattern = Pattern.compile("^[a-zA-Z][0-9]{4}"); Matcher numberMatcher = numberPattern.matcher(email.toLowerCase()); if (!numberMatcher.find()) { response.getWriter().println("????????"); session.invalidate(); return; } String studentNumber = numberMatcher.group(); String key = DigestUtils.md5Hex(String.valueOf(new Date().getTime())); session.setAttribute("studentNumber", studentNumber); session.setAttribute("key", key); //md5?? registerData(studentNumber, key, session); response.sendRedirect("/"); } else { response.getWriter().println("????????"); session.invalidate(); } }