Example usage for javax.servlet.http HttpServletRequest getPathInfo

List of usage examples for javax.servlet.http HttpServletRequest getPathInfo

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getPathInfo.

Prototype

public String getPathInfo();

Source Link

Document

Returns any extra path information associated with the URL the client sent when it made this request.

Usage

From source file:net.zcarioca.jmx.servlet.handlers.RestRequestHandler.java

public Object getResponse(HttpServletRequest request) throws Exception {
    String path = request.getPathInfo();
    if (StringUtils.isBlank(path)) {
        throw new InvalidObjectException("Path not found");
    }//www  .j  a  va2 s. com
    for (RestRequestPathProcessor processor : processors) {
        if (processor.getPathPattern().matcher(path).matches()) {
            return processor.getResponse(request, path);
        }
    }
    return null;
}

From source file:com.ecyrd.jspwiki.url.SilverpeasURLConstructor.java

/**
 * This method is not needed for the DefaultURLConstructor.
 * @param request The HTTP Request that was used to end up in this page.
 * @return "Wiki.jsp", "PageInfo.jsp", etc. Just return the name, JSPWiki will figure out the
 * page.//from w w  w  .ja v a2 s .c  o m
 */
public String getForwardPage(HttpServletRequest request) {
    String basePath = request.getPathInfo();
    return "wiki" + basePath;
}

From source file:org.ngrinder.infra.spring.Redirect404DispatcherServlet.java

/**
 * Redirect to error 404 when the /svn/ is not included in the path.
 *
 * @param request  current HTTP requests
 * @param response current HTTP response
 * @throws Exception if preparing the response failed
 *//*  ww w  .  j ava2  s .  co m*/
protected void noHandlerFound(HttpServletRequest request, HttpServletResponse response) throws Exception {
    if (!request.getPathInfo().startsWith("/svn/")) {
        if (request.getPathInfo().contains("/api")) {
            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
            response.setContentType("application/json; charset=UTF-8");
            String requestUri = urlPathHelper.getRequestUri(request);
            JsonObject object = new JsonObject();

            object.addProperty(JSON_SUCCESS, false);
            object.addProperty(JSON_CAUSE,
                    "API URL " + requestUri + " [" + request.getMethod() + "] does not exist.");
            response.getWriter().write(gson.toJson(object));
            response.flushBuffer();
        } else {
            if (pageNotFoundLogger.isWarnEnabled()) {
                String requestUri = urlPathHelper.getRequestUri(request);
                pageNotFoundLogger.warn("No mapping found for HTTP request with URI [" + requestUri
                        + "] in DispatcherServlet with name '" + getServletName() + "'");
            }
            response.sendRedirect("/error_404");
        }
    }
}

From source file:org.openmhealth.dsu.controller.GenericExceptionHandlingControllerAdvice.java

@ExceptionHandler(AuthenticationCredentialsNotFoundException.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
public void handleAuthenticationCredentialsNotFoundException(Exception e, HttpServletRequest request) {

    log.debug("A {} request for '{}' failed authentication.", request.getMethod(), request.getPathInfo(), e);
}

From source file:com.thinkberg.webdav.HeadHandler.java

public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
    FileObject object = VFSBackend.resolveFile(request.getPathInfo());

    if (object.exists()) {
        if (FileType.FOLDER.equals(object.getType())) {
            response.sendError(HttpServletResponse.SC_FORBIDDEN);
        } else {/*from   w  ww  .  j  a  v  a2s  . co m*/
            setHeader(response, object.getContent());
        }
    } else {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
    }
}

From source file:com.thinkberg.webdav.UnlockHandler.java

public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
    FileObject object = VFSBackend.resolveFile(request.getPathInfo());
    String lockTokenHeader = request.getHeader("Lock-Token");
    String lockToken = lockTokenHeader.substring(1, lockTokenHeader.length() - 1);
    LOG.debug("UNLOCK(" + lockToken + ")");

    if (LockManager.getInstance().releaseLock(object, lockToken)) {
        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
    } else {// w w w  . j  a va2 s  . c  o  m
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    }
}

From source file:com.cloudera.oryx.kmeans.serving.web.AssignServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    CharSequence pathInfo = request.getPathInfo();
    if (pathInfo == null) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path");
        return;//from ww  w . ja v  a2  s.  c om
    }
    String line = pathInfo.subSequence(1, pathInfo.length()).toString();
    Generation generation = getGenerationManager().getCurrentGeneration();
    if (generation == null) {
        response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE,
                "API method unavailable until model has been built and loaded");
        return;
    }

    RealVector vec = generation.toVector(DelimitedDataUtils.decode(line));
    if (vec == null) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Wrong column count");
        return;
    }

    int assignment = DistanceToNearestServlet.findClosest(generation, vec).getClosestCenterId();
    response.getWriter().write(Integer.toString(assignment));
}

From source file:gallery.web.controller.misc.PathController.java

@RequestMapping
@ResponseBody/*from   w  w w  . jav a2 s .  c o m*/
public String hello(HttpServletRequest request) {
    logger.info("encoding=" + request.getCharacterEncoding());

    logger.info("info=" + request.getPathInfo());
    logger.info("uri=" + request.getRequestURI());
    logger.info("hello");

    return "hello world<br>" + "info=" + request.getPathInfo() + "<br>uri=" + request.getRequestURI();
}

From source file:io.specto.hoverfly.recorder.HoverflyFilter.java

private HoverflyRecording.HoverFlyRequest recordRequest(final HttpServletRequest request) throws IOException {
    final String path = request.getPathInfo();
    final String query = request.getQueryString();
    final String requestMethod = request.getMethod();
    final String destination = simulatedBaseUrl;
    final String requestBody = request.getReader() != null ? CharStreams.toString(request.getReader()) : "";
    return new HoverflyRecording.HoverFlyRequest(path, requestMethod, destination, query, requestBody);
}

From source file:com.kaanha.reports.web.controller.ReportController.java

@ModelAttribute("validatedRequest")
public ValidatedRequest validate(@RequestParam(required = true) String jwt,
        @RequestParam(value = "user_id", required = true) String username,
        @RequestParam(required = false) String link, @RequestParam(required = false) String lic,
        HttpServletRequest request) throws Exception {
    if (StringUtils.isBlank(link) && !request.getPathInfo().endsWith("hosted")) {
        if (lic != null) {
            if ("none".equals(lic)) {
                throw new AccessDeniedException(
                        "Sorry, we are unable to detect an active license. Please make sure that you have an active subscription to the 'All-In-One JIRA Reports' plugin. If you were using a trial version, then your trial period may have expired. Please contact your JIRA administrator to renew the license.");
            }/*from w w w.ja va 2 s. com*/
        }
        Tenant tenant = validatorService.validateJWT(jwt);
        User user = userService.findOrSaveUser(username, tenant);
        ValidatedRequest validatedRequest = new ValidatedRequest();
        validatedRequest.setTenant(tenant);
        validatedRequest.setUser(user);
        return validatedRequest;
    }
    return null;
}