List of usage examples for javax.servlet.http HttpServletRequest getContextPath
public String getContextPath();
From source file:com.netsteadfast.greenstep.sys.GreenStepBaseFormAuthenticationFilter.java
@Override protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request, ServletResponse response) throws Exception { HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; if (!this.isAjaxRequest(httpServletRequest)) { httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + this.getSuccessUrl()); } else {/* ww w. j a va2 s . c om*/ response.setCharacterEncoding("UTF-8"); response.setContentType("application/json"); response.getWriter().write(Constants.NO_AUTHZ_JSON_DATA); } return false; }
From source file:com.netsteadfast.greenstep.sys.GreenStepMobileFormAuthenticationFilter.java
@Override protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request, ServletResponse response) throws Exception { HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; if (!this.isAjaxRequest(httpServletRequest)) { httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + this.getSuccessUrl()); } else {//from w w w .ja va2 s.c o m response.setCharacterEncoding(Constants.BASE_ENCODING); response.setContentType("application/json"); response.getWriter().write(Constants.NO_AUTHZ_JSON_DATA); } return false; }
From source file:com.qperior.gsa.oneboxprovider.QPOneBoxProviderServlet.java
/** * Called by the application server's servlet runner when GET method * requests are made for this servlet. OneBox clients (such as the * Google Search Appliance) make HTTP requests to OneBox providers * exclusivley using the GET method.//from w ww . ja v a2 s . c o m */ @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logHeaders(request); this.webAppBaseURL = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/"; processRequest(request, response); }
From source file:controllerClasses.security.SiteuserControl.java
public void callEditor() { HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext() .getRequest();// www . ja v a 2s. c o m String url = req.getRequestURL().toString(); url = url.substring(0, url.length() - req.getRequestURI().length()) + req.getContextPath() + "/index.xhtml"; String password = passGenerator(); Siteuser su = this.user; su.setPassword(encryptPassword(password)); suF.edit(su); String line = url + " Password: " + password + " Username: " + su.getUsername() + ""; setText(line); }
From source file:org.fcrepo.http.commons.session.SessionFactory.java
/** * Extract the id embedded at the beginning of a request path * * @param servletRequest the servlet request * @param prefix the prefix for the id/*from ww w . ja v a2 s.com*/ * @return the found id or null */ protected String getEmbeddedId(final HttpServletRequest servletRequest, final Prefix prefix) { String requestPath = servletRequest.getPathInfo(); // http://stackoverflow.com/questions/18963562/grizzlys-request-getpathinfo-returns-always-null if (requestPath == null && servletRequest.getContextPath().isEmpty()) { requestPath = servletRequest.getRequestURI(); } String id = null; if (requestPath != null) { final String pathPrefix = prefix.getPrefix(); final String[] part = requestPath.split("/"); if (part.length > 1 && part[1].startsWith(pathPrefix)) { id = part[1].substring(pathPrefix.length()); } } return id; }
From source file:org.kuali.mobility.knowledgebase.controllers.KnowledgeBaseController.java
@RequestMapping(value = "/{documentId}", method = RequestMethod.GET) public String getKnowledgeBaseDocument(HttpServletRequest request, Model uiModel, @PathVariable("documentId") String documentId) { uiModel.addAttribute("test", "test2"); String kbdoc = null;/*from ww w . j a v a 2 s . c om*/ try { Map<String, Object> transformerParameters = new HashMap<String, Object>(); transformerParameters.put("linkurl", request.getContextPath() + "/knowledgebase/"); kbdoc = knowledgeBaseService.getConvertedKnowledgeBaseDocument(documentId, "knowledge_base", transformerParameters); uiModel.addAttribute("kbdoc", kbdoc); } catch (Exception e) { LOG.error(e.getMessage(), e); } return "knowledgebase/document"; }
From source file:com.google.code.pathlet.web.PathletAjaxProcessor.java
/** * Retrieves the current request servlet path. * Deals with differences between servlet specs (2.2 vs 2.3+) * * @param request the request//from ww w. ja v a 2 s . c o m * @return the servlet path */ private String getServletPath(HttpServletRequest request) { String servletPath = request.getServletPath(); if (ValueUtils.notEmpty(servletPath)) { return servletPath; } String requestUri = request.getRequestURI(); int startIndex = request.getContextPath().equals("") ? 0 : request.getContextPath().length(); int endIndex = request.getPathInfo() == null ? requestUri.length() : requestUri.lastIndexOf(request.getPathInfo()); if (startIndex > endIndex) { // this should not happen endIndex = startIndex; } return requestUri.substring(startIndex, endIndex); }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateTriggerController.java
@RequestMapping(value = "/createtrigger", method = RequestMethod.GET) public String createTrigger(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. ja v a 2 s. com*/ 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 Trigger"); NewTrigger newTrigger = new NewTrigger(); if (request.getParameter("settablename") != null) { model.addAttribute("tableName", request.getParameter("settablename")); } model.addAttribute("triggerAttribute", newTrigger); TableDAO tableDAO = GemFireXDWebDAOFactory.getTableDAO(); List<Table> tables = tableDAO.retrieveTableList((String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key"), "tables"); model.addAttribute("tables", tables); // This will resolve to /WEB-INF/jsp/create-trigger.jsp return "create-trigger"; }
From source file:org.iti.agrimarket.view.UpdateOfferController.java
/** * @Author Amr delete one offer from the Fixed offers table * @param offerid its the id of the offer * @return json opject {"success":1} if success * @return json opject {"success":0} if deletion error * */// www . j a v a 2s. c o m @RequestMapping(method = RequestMethod.GET, value = "/removeoffer.htm") public String removeOffer(@RequestParam("offerid") Integer offerId, HttpServletRequest request, HttpServletResponse response, Model model) { System.out.println("in delete offer"); offerService.deleteOffer(offerId); try { response.sendRedirect(request.getContextPath() + "/web/profile.htm"); } catch (IOException ex) { java.util.logging.Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } User oldUser = (User) request.getSession().getAttribute("user"); if (oldUser != null) { User user = userService.getUserEager(oldUser.getId()); request.getSession().setAttribute("user", user); model.addAttribute("user", user); } return "profile"; }