List of usage examples for javax.servlet.http HttpServletRequest getRequestURI
public String getRequestURI();
From source file:fr.lille1_univ.car_tprest.jetty.web.UpweeController.java
/** * An helper function that is used to render the path from a request *///from w w w . ja v a2s .co m public String getFullFileRequestPath(String pattern, HttpServletRequest request, String filename) { String tail = new AntPathMatcher().extractPathWithinPattern(pattern, request.getRequestURI()); return tail += "/" + filename; }
From source file:com.orange.cepheus.cep.controller.NgsiController.java
@ExceptionHandler({ TypeNotFoundException.class }) public ResponseEntity<Object> typeNotFoundExceptionHandler(HttpServletRequest req, TypeNotFoundException typeNotFoundException) { logger.error("Type not found: {}", typeNotFoundException.getTypeName()); return errorResponse(req.getRequestURI(), new StatusCode(CodeEnum.CODE_472, typeNotFoundException.getTypeName())); }
From source file:inti.ws.spring.resource.ResourceController.java
@RequestMapping(value = "/**/*.*", method = RequestMethod.GET) public void resource(HttpServletRequest request, HttpServletResponse response) throws Exception { String uri = request.getRequestURI(); List<ResourceConfig> configs = configProvider.getResourceConfigs(request); if (!ctx.getContextPath().equals("")) { uri = uri.replaceFirst(ctx.getContextPath(), ""); }// ww w .j a v a 2 s . c om if (LOGGER.isDebugEnabled()) { LOGGER.debug("resource - handling request for uri={}", uri); LOGGER.debug("resource - searching in={}", configs); } if (configs != null) { for (ResourceConfig config : configs) { for (Map.Entry<String, ? extends WebResource> resource : config.getResources().entrySet()) { WebResource webResource = resource.getValue(); if (webResource.getRoute() != null && pathMatcher.match(webResource.getRoute(), uri)) { LOGGER.debug("resource - resource found for uri={}", uri); resource(resource.getKey(), resource.getValue(), request, response, config.getSettings()); return; } } } } throw new NotFoundException("resource not found: " + uri); }
From source file:com.baomidou.kisso.web.interceptor.SSOPermissionInterceptor.java
/** * /*from www. j a va 2 s . c o m*/ * <p> * ??? 403 illegalUrl ???? * </p> * * @param request * @param response * @return * @throws Exception */ protected boolean unauthorizedAccess(HttpServletRequest request, HttpServletResponse response) throws Exception { logger.fine(" request 403 url: " + request.getRequestURI()); if (HttpUtil.isAjax(request)) { /* AJAX 403 ??? */ HttpUtil.ajaxStatus(response, 403, "ajax Unauthorized access."); } else { /* HTTP */ if (illegalUrl == null || "".equals(illegalUrl)) { response.sendError(403, "Forbidden"); } else { response.sendRedirect(illegalUrl); } } return false; }
From source file:org.toobsframework.pres.base.HandlerBase.java
@Override public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { if (logger.isDebugEnabled()) { logger.debug("handleRequestInternal(" + request.getRequestURI() + ")"); }/*from w w w. j av a 2 s.c o m*/ UrlDispatchInfo dispatchInfo = dispatchStrategy.resolveDispatchInfo(request); if (dispatchInfo == null) { dispatchInfo = new UrlDispatchInfo(request.getRequestURI(), null, null); dispatchInfo.setError(true); request.setAttribute(PresConstants.TOOBS_EXCEPTION_ATTR_NAME, new DispatchException(request.getRequestURI())); } if (response.containsHeader(PresConstants.TOOBS_EXCEPTION_HEADER_NAME)) { dispatchInfo.setError(true); } return handleRequestInternal(request, response, dispatchInfo); }
From source file:technology.tikal.gae.http.cache.AbstractCacheController.java
public boolean isQueryRelated(HttpServletRequest request, HttpServletResponse response) { String requestUri = request.getRequestURI(); if (requestUri != null && requestUri.matches(resourceUriPattern)) { return true; }/*www . ja v a 2 s. c o m*/ return false; }
From source file:com.ms.app.web.commons.statics.StaticResourcesServie.java
/** * ??// w ww . j a v a 2s.c o m * * @param request * @return */ public StaticResources getResource(HttpServletRequest request) { if (request == null) { return defaultResource; } if (resources == null || resources.isEmpty()) { return defaultResource; } String urlPath = request.getRequestURI(); return getResource(urlPath); }
From source file:com.github.wnameless.spring.bulkapi.DefaultBulkApiService.java
private URI computeUri(HttpServletRequest servReq, BulkOperation op) { String rawUrl = servReq.getRequestURL().toString(); String rawUri = servReq.getRequestURI().toString(); if (op.getUrl() == null || isBulkPath(op.getUrl())) { throw new BulkApiException(UNPROCESSABLE_ENTITY, "Invalid URL(" + rawUri + ") exists in this bulk request"); }/*from w w w .jav a 2 s.c o m*/ URI uri; try { String servletPath = rawUrl.substring(0, rawUrl.indexOf(rawUri)); uri = new URI(servletPath + urlify(op.getUrl())); } catch (URISyntaxException e) { throw new BulkApiException(UNPROCESSABLE_ENTITY, "Invalid URL(" + urlify(op.getUrl()) + ") exists in this bulk request"); } if (!validator.validatePath(urlify(op.getUrl()), httpMethod(op.getMethod()))) { throw new BulkApiException(UNPROCESSABLE_ENTITY, "Invalid URL(" + urlify(op.getUrl()) + ") exists in this bulk request"); } return uri; }
From source file:ar.com.zauber.commons.spring.web.controllers.AbstractRestishController.java
/** @see AbstractController#handleRequestInternal(HttpServletRequest, * HttpServletResponse) @throws Exception on error */ public final ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response) throws Exception { final String uri = request.getRequestURI().substring(request.getContextPath().length()); final String[] patharray = uri.split("/"); ModelAndView ret;// ww w . j ava 2 s.c o m if (!uri.endsWith("/")) { ret = new ModelAndView(springWebUtil.createRedirect(uri + "/")); } else if (patharray.length == firstIndex) { ret = list(request, response); } else if (patharray.length == firstIndex + 1) { final Long id = (Long) seoStrategy.getIdFromSEOFriendly(patharray[firstIndex]); if (id == null) { throw new NoSuchEntityException(patharray[firstIndex]); } ret = entity(id, request, response); } else if (patharray.length == firstIndex + 2) { final Long id = (Long) seoStrategy.getIdFromSEOFriendly(patharray[firstIndex]); if (id == null) { throw new NoSuchEntityException(patharray[firstIndex]); } if (callEntityOnRelationship) { ret = entity(id, request, response); } final String action = patharray[firstIndex + 1]; try { final Method m = getClass().getMethod(action, long.class, HttpServletRequest.class, HttpServletResponse.class); ret = (ModelAndView) m.invoke(this, id, request, response); } catch (NoSuchMethodException e) { ret = onMethodFound(request, response); } } else { throw new IllegalArgumentException(); } return ret; }
From source file:hr.fer.zemris.vhdllab.web.LogRequestHeadersFilter.java
@Override protected void beforeRequest(HttpServletRequest request, String message) { if (logger.isDebugEnabled()) { Enumeration<?> headerNames = request.getHeaderNames(); StringBuilder sb = new StringBuilder(2000); sb.append("Request headers for uri: ").append(request.getRequestURI()); sb.append("\n"); while (headerNames.hasMoreElements()) { String name = (String) headerNames.nextElement(); String value = request.getHeader(name); sb.append(name).append(":").append(value).append("\n"); }/*from w w w . j ava 2 s .co m*/ logger.debug(sb.toString()); } }