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:com.jaspersoft.jasperserver.rest.services.RESTRole.java

@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServiceException {
    WSRole role = restUtils.populateServiceObject(req.getPathInfo(), req.getParameterMap(), WSRole.class);
    WSRoleSearchCriteria criteria = restUtils.populateServiceObject(req.getPathInfo(), req.getParameterMap(),
            WSRoleSearchCriteria.class);

    WSRole[] roles = null;/*from w w  w  .  ja  v  a  2s .  c  o m*/
    try {
        roles = userAndRoleManagementService.findRoles(criteria);
        if (roles != null && roles.length != 0) {
            userAndRoleManagementService.deleteRole(role);
            if (log.isDebugEnabled()) {
                log.debug(role + " role were deleted");
            }
        } else {
            throw new ServiceException(HttpServletResponse.SC_NOT_FOUND, "role: " + role + " was not found");
        }
    } catch (AxisFault axisFault) {
        throw new ServiceException(HttpServletResponse.SC_BAD_REQUEST, axisFault.getLocalizedMessage());
    }
    restUtils.setStatusAndBody(HttpServletResponse.SC_OK, resp, "");
}

From source file:com.jaspersoft.jasperserver.rest.services.RESTAttribute.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServiceException {
    restUtils.setStatusAndBody(HttpServletResponse.SC_OK, resp, generateProfileAttributeReport(
            attributesRemoteService.getAttributesOfUser(restUtils.extractResourceName(req.getPathInfo()))));
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.java

@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
    if (!isAuthorizedToDisplayPage(req, resp, REQUIRED_ACTION)) {
        return;//w  ww.j a  v a  2  s .c o  m
    }

    try {
        String action = req.getPathInfo();
        if (ACTION_SELECT.equals(action)) {
            new DumpModelsAction(req, resp).redirectToFilename();
        } else if (StringUtils.startsWith(action, ACTION_DUMP)) {
            new DumpModelsAction(req, resp).dumpModels();
        } else {
            super.doGet(req, resp);
        }
    } catch (BadRequestException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.dspace.webmvc.controller.ResourceController.java

protected String getPath(HttpServletRequest req) {
    String servletPath = req.getServletPath();
    return servletPath + (StringUtils.isEmpty(req.getPathInfo()) ? "" : req.getPathInfo());
}

From source file:net.buffalo.web.servlet.ApplicationServlet.java

protected void doRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    RequestContextUtil.createRequestContext(getServletContext(), request, response);
    String pathInfo = request.getPathInfo();

    LOG.debug("request path info: " + pathInfo);
    RequestWorker worker = null;/*  w  ww  .  j  ava 2 s. c  om*/
    if (pathInfo == null || pathInfo.equals("/")) {
        worker = new ViewWorker();
    } else if (pathInfo.startsWith("/view/")) {
        worker = new ViewWorker();
    } else if (pathInfo.startsWith("/buffalo/")) {
        worker = new BuffaloWorker();
    } else if (pathInfo.startsWith("/upload/")) {
        worker = new UploadWorker();
    } else {
        throw new ServletException("Cannot find the request worker!");
    }

    try {
        worker.validate(request, response);
    } catch (ValidationException ex) {
        throw new ServletException("Service validation error", ex);
    }

    worker.processRequest(request, response);
}

From source file:ch.puzzle.modjprof.control.ControlServlet.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    String pathInfo = request.getPathInfo();
    PrintWriter out = response.getWriter();
    try {/*from  ww w  .  j a  v a  2 s. c o  m*/
        printResponseHeader(out, pathInfo);
        evaluateCommandAndExecuteIt(pathInfo, getBaseUri(request), response, out);
        printResponseFooter(out);
    } finally {
        out.close();
    }
}

From source file:com.sun.socialsite.web.rest.servlets.ImageServlet.java

/**
 * Handles the HTTP <code>GET</code> method.
 * @param req servlet request/*ww  w  .  j a v a  2s. com*/
 * @param resp servlet response
 */
@Override
protected final void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    String itemName = ((req.getPathInfo() != null) ? req.getPathInfo().substring(1) : null);
    if (itemName != null)
        itemName = URLDecoder.decode(itemName, "UTF-8");

    Result result = getResult(itemName);

    if ((result == null) || (result.imageType == null) || (result.imageType.equals(""))) {
        RequestDispatcher rd = req.getRequestDispatcher(defaultImage);
        rd.forward(req, resp);
        return;
    }

    long ifModifiedTime = 0L;
    if (req.getHeader("If-Modified-Since") != null) {
        try {
            ifModifiedTime = getDateFormat().parse(req.getHeader("If-Modified-Since")).getTime();
        } catch (Throwable intentionallyIgnored) {
        }
    }

    // We've got an EHCache GenericResponseWrapper, it ignores date headers
    //resp.setDateHeader("Last-Modified", lastModifiedString);
    resp.setHeader("Last-Modified", getDateFormat().format(result.lastUpdate));
    resp.setHeader("ETag", result.eTag);

    // Force clients to revalidate each time
    // See RFC 2616 (HTTP 1.1 spec) secs 14.21, 13.2.1
    // We've got an EHCache GenericResponseWrapper, it ignores date headers
    //resp.setDateHeader("Expires", 0);
    resp.setHeader("Expires", epoch);

    // We may also want this (See 13.2.1 and 14.9.4)
    // response.setHeader("Cache-Control","must-revalidate");

    if (result.lastUpdate.getTime() > ifModifiedTime || !handleConditionalGets) {
        resp.setContentType(result.imageType);
        resp.setContentLength(result.imageBytes.length);
        OutputStream out = resp.getOutputStream();
        out.write(result.imageBytes, 0, result.imageBytes.length);
        out.close();
    } else {
        resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
    }

    return;
}

From source file:com.haulmont.cuba.web.controllers.StaticContentController.java

protected String getPath(HttpServletRequest req) {
    String path = ControllerUtils.getControllerPath(req);
    String pathInfo = coalesce(req.getPathInfo(), "");
    return path + pathInfo;
}

From source file:org.geomajas.gwt.server.mvc.GwtResourceController.java

protected URL[] getRequestResourceUrls(String rawResourcePath, HttpServletRequest request)
        throws MalformedURLException {
    URL[] resources = super.getRequestResourceUrls(rawResourcePath, request);
    // try web context (prepending servlet path)
    if (resources == null || resources.length == 0) {
        rawResourcePath = request.getServletPath() + request.getPathInfo();
        resources = super.getRequestResourceUrls(rawResourcePath, request);
    }//  w  w w  . j a v a  2  s . c  o  m
    return resources;
}

From source file:org.shredzone.commons.view.impl.ViewServiceImpl.java

@Override
public void handleRequest(HttpServletRequest req, HttpServletResponse resp) throws Exception {
    String path = req.getPathInfo();
    if (path == null) {
        path = "";
    }/*from w  w w . jav a 2  s .  c om*/

    interceptors.forEach(it -> it.onRequest(req, resp));

    String renderViewName = null;

    try {
        ViewContext context = getViewContext();
        context.putTypedArgument(ServletContext.class, servletContext);
        context.putTypedArgument(HttpServletResponse.class, resp);
        renderViewName = invokeView(path);
    } catch (ErrorResponseException ex) {
        if (log.isDebugEnabled()) {
            StringBuilder sb = new StringBuilder();
            sb.append("View handler returned HTTP status ").append(ex.getResponseCode());
            if (ex.getMessage() != null) {
                sb.append(" (").append(ex.getMessage()).append(')');
            }
            sb.append(" for path '").append(path).append('\'');
            log.debug(sb.toString());
        }

        for (ViewInterceptor interceptor : interceptors) {
            if (interceptor.onErrorResponse(ex, req, resp)) {
                return;
            }
        }

        if (ex.getMessage() != null) {
            resp.sendError(ex.getResponseCode(), ex.getMessage());
        } else {
            resp.sendError(ex.getResponseCode());
        }
        return;
    }

    if (renderViewName != null) {
        for (ViewInterceptor interceptor : interceptors) {
            String newViewName = interceptor.onRendering(renderViewName, req, resp);
            if (newViewName != null) {
                renderViewName = newViewName;
            }
        }

        String fullViewPath = getTemplatePath(renderViewName);
        RequestDispatcher dispatcher = servletContext.getRequestDispatcher(fullViewPath);
        dispatcher.forward(req, resp);
    }
}