List of usage examples for javax.servlet.http HttpServletResponse sendRedirect
public void sendRedirect(String location) throws IOException;
From source file:cn.vlabs.duckling.vwb.ui.servlet.OauthLogoutServlet.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { boolean isSubLogout = StringUtils.equals(request.getParameter("sub"), "1"); if (isSubLogout) { String state = request.getParameter("state"); response.sendRedirect(state); } else {/* w w w. ja v a 2s .c o m*/ VWBContext context = VWBContext.createContext(request, VWBCommand.LOGOUT, null); VWBContext adminSiteContext = getAdminLogoutContext(request); VWBSession vwbsession = context.getVWBSession(); if (vwbsession.isAuthenticated()) { String localURL = ""; String next = request.getParameter("next"); if (next != null) { localURL = next; } else { String referer = request.getHeader("Referer"); if (referer != null) { localURL = referer; } else { localURL = context.getFrontPage(); } } if (!localURL.startsWith("http")) { String baseURL = context.getBaseURL().replaceAll(context.getBasePath(), ""); localURL = baseURL + localURL; } localURL = adminSiteContext.getURL(VWBContext.LOGOUT, "/logout", "sub=1&state=" + URLEncoder.encode(localURL, "UTF-8"), true); String redirectURL = makeSSOLogoutURL(adminSiteContext, localURL); VWBContext.getContainer().getAuthenticationService().logout(request); response.sendRedirect(redirectURL); } else { log.info("User's session is invalid, just redirect to home page."); response.sendRedirect(context.getFrontPage()); } } }
From source file:edu.emory.cci.aiw.cvrg.eureka.servlet.filter.HaveUserRecordFilter.java
private void sendForbiddenError(HttpServletResponse servletResponse, HttpServletRequest servletRequest, boolean created) throws IOException { if (this.properties.isRegistrationEnabled()) { servletResponse.setStatus(HttpServletResponse.SC_FORBIDDEN); if (created) { servletResponse.sendRedirect(servletRequest.getContextPath() + "/logout?awaitingActivation=true"); } else {/* w w w . j a v a2 s . c om*/ servletResponse.sendRedirect(servletRequest.getContextPath() + "/logout?notRegistered=true"); } } else { servletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); } }
From source file:com.hp.avmon.home.web.HomeController.java
@RequestMapping("/logout") public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException { // ?/*w ww. ja va 2 s .c o m*/ request.getSession().removeAttribute(Config.CURRENT_USER); logger.debug("logout !!!"); response.sendRedirect("modules/index.jsp"); }
From source file:vmware.au.se.sqlfireweb.controller.MemberController.java
@RequestMapping(value = "/members", method = RequestMethod.GET) public String showDiskstores(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { javax.servlet.jsp.jstl.sql.Result allMemberInfoResult = null; if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/sqlfireweb/login"); return null; }//from w ww . j a v a2 s . co m logger.debug("Received request to show members"); MemberDAO mbrDAO = ISQLFireDAOFactory.getMemberDAO(); String memberAction = request.getParameter("memberAction"); if (memberAction != null) { logger.debug("memberAction = " + memberAction); if (memberAction.equals("ALLMEMBEREVENTINFO")) { allMemberInfoResult = mbrDAO.getMemberInfo((String) request.getParameter("memberId"), (String) session.getAttribute("user_key")); model.addAttribute("allMemberInfoResult", allMemberInfoResult); model.addAttribute("memberid", (String) request.getParameter("memberId")); } } List<Member> members = mbrDAO.retrieveMembers((String) session.getAttribute("user_key")); model.addAttribute("members", members); model.addAttribute("records", members.size()); model.addAttribute("estimatedrecords", members.size()); // This will resolve to /WEB-INF/jsp/members.jsp return "members"; }
From source file:eionet.web.filter.ContentNegotiationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding("utf-8"); HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; String requestUrl = httpRequest.getRequestURL().toString(); if (!StringUtils.endsWithIgnoreCase(requestUrl, "/rdf")) { if (isRdfXmlPreferred(httpRequest)) { String redirectUrl = requestUrl + "/rdf"; httpResponse.sendRedirect(redirectUrl); return; }// w ww . j a va 2 s.c o m } chain.doFilter(request, response); }
From source file:alpha.portal.webapp.controller.UserSearchController.java
/** * On submit./*from ww w. j ava2s . c o m*/ * * @param request * the request * @param response * the response * @param model * the model * @return the model * @throws Exception * the exception */ @RequestMapping(method = RequestMethod.POST) public Model onSubmit(final HttpServletRequest request, final HttpServletResponse response, final Model model) throws Exception { final String userName = request.getParameter("lastName"); final String caseId = request.getParameter("case"); if (request.getParameter("cancel") != null) { response.sendRedirect("caseform?caseId=" + caseId); return model; } if (userName != null) { final List<User> users = this.userManager.getAll(); final List<User> res = new LinkedList<User>(); for (final User u : users) { if (u.getLastName().toLowerCase().contains(userName.toLowerCase())) { res.add(u); } } model.addAttribute("users", res); } final String[] userIds = request.getParameterValues("sel[]"); if (ArrayUtils.isNotEmpty(userIds) && StringUtils.isNotEmpty(caseId)) { AlphaCase aCase = this.caseManager.get(caseId); for (final String userId : userIds) { final User participant = this.userManager.getUser(userId); aCase.addParticipant(participant); } aCase = this.caseManager.save(aCase); response.sendRedirect("caseform?caseId=" + caseId); } return model; }
From source file:cn.vlabs.umt.ui.actions.ActivationSecondaryAction.java
/** * /*ww w . j av a 2 s . c om*/ * */ public synchronized ActionForward activeSecondaryEmail(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActivationForm data = (ActivationForm) form; boolean isValid = getTokenService().isValid(data.getTokenid(), data.getRandom(), Token.OPERATION_ACTIVATION_SECONDARY_EMAIL); //token if (!isValid) { response.sendRedirect(ShowPageAction.getMessageUrl(request, "active.login.email.fail")); return null; } Token token = getTokenService().getTokenById(data.getTokenid()); User user = getUserService().getUserByUid(token.getUid()); AbstractDoActivation doAction = new DoActivationServiceForSecondary(request, response, token, user, data); return doAction.doActivation(); }
From source file:csns.web.filter.RegistrationFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String contextPath = request.getContextPath(); String path = request.getRequestURI().substring(contextPath.length()); if (SecurityUtils.isAuthenticated() && SecurityUtils.getUser().isTemporary() && !isPassThrough(path)) { response.sendRedirect(contextPath + "/register"); return;// w ww .j a v a2s. co m } filterChain.doFilter(request, response); }
From source file:at.gv.egiz.pdfas.web.servlets.ErrorPage.java
protected void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (PdfAsHelper.getFromDataUrl(request)) { // redirect to here! response.sendRedirect(PdfAsHelper.generateErrorURL(request, response)); return;//from w ww. j a v a 2 s. co m } else { String errorURL = PdfAsHelper.getErrorURL(request, response); Throwable e = PdfAsHelper.getSessionException(request, response); StatisticEvent statisticEvent = PdfAsHelper.getStatisticEvent(request, response); if (statisticEvent != null) { if (!statisticEvent.isLogged()) { statisticEvent.setStatus(Status.ERROR); statisticEvent.setException(e); if (e instanceof PDFASError) { statisticEvent.setErrorCode(((PDFASError) e).getCode()); } statisticEvent.setEndNow(); statisticEvent.setTimestampNow(); StatisticFrontend.getInstance().storeEvent(statisticEvent); statisticEvent.setLogged(true); } } String message = PdfAsHelper.getSessionErrMessage(request, response); if (errorURL != null && WebConfiguration.isProvidePdfURLinWhitelist(errorURL)) { String template = PdfAsHelper.getErrorRedirectTemplateSL(); URL url = new URL(errorURL); String errorURLProcessed = url.getProtocol() + "://" + // "http" + ":// url.getHost() + // "myhost" ":" + // ":" url.getPort() + // "8080" url.getPath(); template = template.replace("##ERROR_URL##", errorURLProcessed); String extraParams = UrlParameterExtractor.buildParameterFormString(url); template = template.replace("##ADD_PARAMS##", extraParams); String target = PdfAsHelper.getInvokeTarget(request, response); if (target == null) { target = "_self"; } template = template.replace("##TARGET##", StringEscapeUtils.escapeHtml4(target)); if (e != null && WebConfiguration.isShowErrorDetails()) { template = template.replace("##CAUSE##", URLEncoder.encode(e.getMessage(), "UTF-8")); } else { template = template.replace("##CAUSE##", ""); } if (message != null) { template = template.replace("##ERROR##", URLEncoder.encode(message, "UTF-8")); } else { template = template.replace("##ERROR##", "Unbekannter Fehler"); } response.setContentType("text/html"); response.getWriter().write(template); response.getWriter().close(); } else { if (errorURL != null) { logger.warn(errorURL + " is not allowed by whitelist"); } String template = PdfAsHelper.getErrorTemplate(); if (message != null) { template = template.replace(ERROR_MESSAGE, message); } else { template = template.replace(ERROR_MESSAGE, "Unbekannter Fehler"); } if (e != null && WebConfiguration.isShowErrorDetails()) { template = template.replace(ERROR_STACK, HTMLFormater.formatStackTrace(e.getStackTrace())); } else { template = template.replace(ERROR_STACK, ""); } response.setContentType("text/html"); response.getWriter().write(template); response.getWriter().close(); } } }
From source file:com.starr.smartbuilds.controller.RegController.java
@RequestMapping(method = { RequestMethod.GET }) public String getReg(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 av a 2 s. c o m resp.sendRedirect("./"); } model.addAttribute("user", new User()); return "register"; }