List of usage examples for javax.servlet.http HttpServletRequest getContextPath
public String getContextPath();
From source file:com.streamsets.lib.security.http.SSOUserAuthenticator.java
boolean isLogoutRequest(HttpServletRequest httpReq) { String logoutPath = httpReq.getContextPath() + "/logout"; return httpReq.getMethod().equals("GET") && httpReq.getRequestURI().equals(logoutPath); }
From source file:org.cloudfoundry.identity.uaa.oauth.AccessController.java
private String getPath(HttpServletRequest request, String path) { String contextPath = request.getContextPath(); if (contextPath.endsWith("/")) { contextPath = contextPath.substring(0, contextPath.lastIndexOf("/") - 1); }//from w w w . j ava2 s. c o m if (path.startsWith("/")) { path = path.substring(1); } return contextPath + "/" + path; }
From source file:com.hp.autonomy.frontend.find.core.web.ControllerUtilsImpl.java
private String getBaseUrl(final HttpServletRequest request) { final String originalUri = (String) request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI); final String requestUri = originalUri != null ? originalUri : request.getRequestURI(); final String path = requestUri.replaceFirst(request.getContextPath(), ""); final int depth = StringUtils.countMatches(path, "/") - 1; return depth <= 0 ? "." : StringUtils.repeat("../", depth); }
From source file:ph.fingra.statisticsweb.controller.DashBoardController.java
/** AppList - Ajax * @param searchParam// w w w . j a va2 s . c o m * @return */ @RequestMapping(value = "/getAppListAjax", method = RequestMethod.POST, produces = "text/plain;charset=UTF-8") public @ResponseBody String getAppListAjax(@ActiveUser FingraphUser activeUser, HttpServletRequest request) { Map<String, Object> paramMap = new HashMap<String, Object>(); DashBoardSearchParam param = new DashBoardSearchParam(); List<App> appList = dashBoardService.getAppList(param); String context = request.getContextPath(); List<MsDropDown> list = new ArrayList<>(); if (appList.size() > 0) { for (App app : appList) { MsDropDown ms = new MsDropDown(); ms.setValue(app.getAppkey()); ms.setText(app.getAppname()); if (app.getPlatform() == 1) {//ios ms.setImage(context + "/resources/img/icon_sel_ios.png"); } else if (app.getPlatform() == 2) {//android ms.setImage(context + "/resources/img/icon_sel_android.png"); } list.add(ms); } } paramMap.put("list", list); return (new Gson()).toJson(paramMap); }
From source file:com.lcw.one.modules.sys.interceptor.LogInterceptor.java
@Override @Transactional(readOnly = false)/* w ww.j av a2 s .com*/ public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { endTime = System.currentTimeMillis(); String requestRri = request.getRequestURI(); String uriPrefix = request.getContextPath() + Global.getRestApiPath(); // ?REST ApiURL if (!StringUtils.startsWith(requestRri, uriPrefix)) { return; } // ? User user = UserUtils.getUser(); if (user == null || user.getId() == null) { return; } // Log log = new Log(); log.setId(UUID.randomUUID().toString()); log.setType(ex == null ? Log.TYPE_ACCESS : Log.TYPE_EXCEPTION); log.setCreateBy(user); log.setCreateDate(new Date()); log.setRemoteAddr(StringUtils.getRemoteAddr(request)); log.setUserAgent(request.getHeader("user-agent")); log.setRequestUri(request.getRequestURI()); log.setMethod(request.getMethod()); log.setParams(buildQueryString(request)); log.setException(ex != null ? ex.toString() : ""); logService.save(log); // TODO ??URL? logger.info(" {type: {}, loginName: {}, uri: {}}, ", log.getType(), user.getLoginName(), log.getRequestUri()); logger.info(":" + (endTime - startTime) + "\tURL:" + request.getRequestURI()); }
From source file:com.r3bl.controller.LoginInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String uri = request.getRequestURI(); if (uri.contains("dashboard")) { Usuario u = (Usuario) request.getSession().getAttribute("usuarioLogado"); if (u == null) { response.sendRedirect(request.getContextPath() + "/login"); return false; }//from w w w . j a va 2 s .co m } return true; }
From source file:com.scooterframework.web.controller.ScooterRequestFilter.java
protected boolean isStaticContentRequest(HttpServletRequest request) { String contextPath = request.getContextPath(); String requestURI = request.getRequestURI(); String staticPath = contextPath + "/" + "static"; return (requestURI.startsWith(staticPath)) ? true : false; }
From source file:eu.planets_project.tb.api.data.util.DigitalObjectRefBean.java
private URI createDownloadUri(String id, String prefix) { // Define the download URI: log.debug("Creating the download URL."); String context = "/testbed"; if (FacesContext.getCurrentInstance() != null) { HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext() .getRequest();/*from ww w . j av a 2 s .c o m*/ context = req.getContextPath(); } URI download = null; try { download = new URI("https", PlanetsServerConfig.getHostname() + ":" + PlanetsServerConfig.getSSLPort(), context + prefix, "fid=" + URLEncoder.encode(id, "UTF-8"), null); /* This can be used if the above is causing problems download = new URI( null, null, context+"/reader/download.jsp","fid="+id, null); */ } catch (URISyntaxException e) { e.printStackTrace(); download = null; } catch (UnsupportedEncodingException e) { e.printStackTrace(); download = null; } log.debug("Created download URI: " + download); return download; }
From source file:de.itsvs.cwtrpc.controller.CacheControlFilter.java
protected PreparedCacheControlUriConfig getPreparedUriConfig(HttpServletRequest request) { final String contextPath; final StringBuilder sb; final String uri; contextPath = request.getContextPath(); sb = new StringBuilder(request.getRequestURI()); if ((contextPath.length() > 0) && (sb.indexOf(contextPath) == 0)) { sb.delete(0, contextPath.length()); }/*from ww w . ja va2 s . co m*/ if ((sb.length() == 0) || (sb.charAt(0) != '/')) { sb.insert(0, '/'); } uri = sb.toString(); if (log.isDebugEnabled()) { log.debug("Checked URI is '" + uri + "'"); } for (PreparedCacheControlUriConfig config : getUriConfigs()) { if ((config.getMethod() == null) || config.getMethod().name().equals(request.getMethod())) { if (config.getValue().matches(uri)) { if (log.isDebugEnabled()) { log.debug("Matching configuration for URI '" + uri + "' and method '" + request.getMethod() + "' is " + config); } return config; } } } if (log.isDebugEnabled()) { log.debug("No matching configuration for URI '" + uri + "' and method '" + request.getMethod() + "'"); } return null; }
From source file:com.lti.system.MyLogoutFilter.java
/** * Allow subclasses to modify the redirection message. * * @param request the request/*ww w .j av a 2 s . c o m*/ * @param response the response * @param url the URL to redirect to * * @throws IOException in the event of any failure */ protected void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url) throws IOException { if (!url.startsWith("http://") && !url.startsWith("https://")) { url = request.getContextPath() + url; } response.sendRedirect(response.encodeRedirectURL(url)); }