Example usage for javax.servlet.http HttpServletRequest getRequestURI

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

Introduction

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

Prototype

public String getRequestURI();

Source Link

Document

Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.

Usage

From source file:iddb.web.security.service.UserServiceFilter.java

/**
 * @param s/*from w w w  . j av a 2s .c  o  m*/
 * @param request
 * @return
 * @throws IOException 
 */
private boolean haveAccess(Subject s, HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String path = req.getRequestURI();
    log.debug("Check path {}", path);
    if (!req.getContextPath().isEmpty()) {
        path = StringUtils.removeStartIgnoreCase(path, req.getContextPath());
    }
    if (!path.startsWith("/")) {
        path = "/" + path;
    } else if (path.startsWith("//")) {
        path = path.substring(1);
    }
    for (String p : urls.keySet()) {
        if (p.endsWith("**")) {
            if (path.startsWith(p.substring(0, p.length() - 2))) {
                return checkRoles(s, req, resp, p);
            }
        } else {
            if (path.equalsIgnoreCase(p)) {
                return checkRoles(s, req, resp, p);
            }
        }
    }
    return true;
}

From source file:uk.org.iay.mdq.server.RequestLogger.java

@Override
protected String createMessage(HttpServletRequest request, String prefix, String suffix) {
    final StringBuilder msg = new StringBuilder();
    msg.append(prefix);/* www.j ava  2s  .  c om*/
    msg.append(request.getMethod());
    msg.append(" for '").append(request.getRequestURI()).append("'");
    if (isIncludeClientInfo()) {
        final String client = request.getRemoteAddr();
        msg.append(" from ").append(client);
    }
    msg.append(suffix);
    return msg.toString();
}

From source file:com.indoqa.httpproxy.HttpClientProxy.java

private String createProxyPath(HttpServletRequest request) {
    String requestURI = request.getRequestURI();

    int proxyMountPathStartPosition = requestURI.indexOf(this.proxyMountPath);

    if (proxyMountPathStartPosition == -1) {
        throw new IllegalArgumentException("Proxy request path needs to start with defined proxyMountPath!");
    }//from  w w  w  . ja v  a  2  s  .  c o m

    StringBuilder pathBuilder = new StringBuilder();

    String pathAfterProxyMount = requestURI
            .substring(proxyMountPathStartPosition + this.proxyMountPath.length());
    pathBuilder.append(this.proxyPathCreator.createPath(pathAfterProxyMount, request));

    return pathBuilder.toString();
}

From source file:net.longfalcon.web.ContentController.java

@RequestMapping("/content/{id:\\d+}/-/**")
public String viewContentUrl(@PathVariable long id, HttpServletRequest httpServletRequest, Model model)
        throws NoSuchResourceException {
    Content indexContent = contentService.getContent(id);
    String url = httpServletRequest.getRequestURI();
    String[] urlParts = url.split("/-");
    String urlPart = urlParts[1];
    if (urlPart.equals(indexContent.getUrl())) {
        model.addAttribute("content", indexContent);
    } else {/*  w ww. j  ava2 s .  co m*/
        throw new NoSuchResourceException();
    }

    return "content";
}

From source file:jp.co.opentone.bsol.framework.web.extension.jsf.RequestLoggingPhaseListener.java

@Override
public void beforePhase(PhaseEvent event) {
    HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext()
            .getRequest();/*from   ww w .j  a  va 2  s .c o  m*/

    log.info("Requested: {} {}", req.getMethod(), req.getRequestURI());
    Enumeration<?> enm = req.getHeaderNames();
    log.info("Header:");
    while (enm.hasMoreElements()) {
        String name = (String) enm.nextElement();
        log.info("   {} = {}", name, req.getHeader(name));
    }

    log.info(" Parameters:");
    @SuppressWarnings("unchecked")
    Map<String, String[]> parameterMap = req.getParameterMap();
    for (Map.Entry<String, String[]> e : parameterMap.entrySet()) {
        log.info("  {} = {}", e.getKey(), StringUtils.join(e.getValue()));
    }
}

From source file:pt.brunorene.rawgit.Proxy.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
 *
 * @param request  servlet request/*from w  ww. j av a 2s  . c  o m*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException      if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String url = ROOT + request.getRequestURI().replace("/rawgit", "");
    try (OutputStream out = response.getOutputStream()) {
        out.write(client.execute(new HttpGet(url), rsp -> {
            try {
                TikaConfig config = TikaConfig.getDefaultConfig();
                Detector detector = config.getDetector();
                byte[] data = EntityUtils.toByteArray(rsp.getEntity());
                TikaInputStream stream = TikaInputStream.get(data);
                Metadata metadata = new Metadata();
                metadata.add(Metadata.RESOURCE_NAME_KEY, url);
                response.setContentType(detector.detect(stream, metadata).toString());
                return data;
            } catch (IOException ex) {
                log.error(null, ex);
                return new byte[0];
            }
        }));
    }
}

From source file:com.surevine.alfresco.audit.listeners.CreateWikiPageAuditEventListener.java

@Override
public void setSpecificAuditMetadata(final Auditable auditable, final HttpServletRequest request,
        final JSONObject json, final BufferedHttpServletResponse response) throws JSONException {

    NodeRef nodeRef = nodeRefResolver.getNodeRef(request.getRequestURI());
    setMetadataFromNodeRef(auditable, nodeRef);

}

From source file:com.thorpora.module.core.error.ErrorLogger.java

public void logServletError(Logger logger, HttpServletRequest request, HttpServletResponse response) {
    String requestFullpath = request.getRequestURI();
    if (request.getQueryString() != null) {
        requestFullpath += "?" + request.getQueryString();
    }/*from  w  ww  .  j  a  v  a 2 s. c om*/
    String msg = String.format("Servlet error [%s] : %s (will forward to /error)", response.getStatus(),
            requestFullpath);
    if (response.getStatus() >= 500) {
        logger.error(msg);
    } else {
        logger.info(msg);
    }
}

From source file:org.apache.nifi.web.server.HostHeaderHandler.java

@Override
public void doScope(String target, Request baseRequest, HttpServletRequest request,
        HttpServletResponse response) throws IOException, ServletException {
    logger.debug("HostHeaderHandler#doScope on " + request.getRequestURI());
    nextScope(target, baseRequest, request, response);
}