Example usage for javax.servlet.http HttpServletRequest getRequestURL

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

Introduction

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

Prototype

public StringBuffer getRequestURL();

Source Link

Document

Reconstructs the URL the client used to make the request.

Usage

From source file:net.roecky.grails.plugins.shiroProtectAny.filters.ShiroAnyUrlProtectionFilter.java

public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
        throws IOException, ServletException {
    final HttpServletRequest req = (HttpServletRequest) request;
    final HttpServletResponse res = (HttpServletResponse) response;

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Invoked filter for '" + req.getRequestURL());
    }/*  ww  w  .  j  a  v  a 2 s  . c o m*/

    // each (!) filtered call requires a valid authentication and permissions
    if (shiroAnyUrlProtection.accessControl(req, res, req.getSession())) {
        // found valid permission, continue the request
        chain.doFilter(request, response);
    }
}

From source file:com.meetme.plugins.jira.gerrit.adminui.AdminServlet.java

private URI getUri(final HttpServletRequest request) {
    StringBuffer builder = request.getRequestURL();

    if (request.getQueryString() != null) {
        builder.append("?");
        builder.append(request.getQueryString());
    }//from w ww. j  a va2s. com

    return URI.create(builder.toString());
}

From source file:edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils.java

private String requestProperties(HttpServletRequest req) {
    @SuppressWarnings("unchecked")
    Map<String, String[]> map = req.getParameterMap();

    String s = req.getRequestURL().append('\n').toString();
    for (String name : new TreeSet<String>(map.keySet())) {
        s += "   " + name + " = " + Arrays.toString(map.get(name)) + '\n';
    }//from w w w  .j  a  va 2 s.c om
    return s.trim();
}

From source file:com.kolich.spring.interceptors.RequestPathInterceptor.java

@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response,
        final Object handler) throws Exception {
    final String url = request.getRequestURL().toString();
    boolean found = false;
    for (final PathMapping pm : mappings_) {
        // Does the incoming request match the request of this mapping?
        if (pm.isWildcardMethod() || pm.getMethod().equalsIgnoreCase(request.getMethod())) {
            if (pm.getMatcher(url).find()) {
                found = true;/* w  w w.j a  v a  2s .c  om*/
                break;
            }
        }
    }
    // If we got here, and found is false, that means that the incoming
    // request path does not match any of our expected mappings.
    if (!found) {
        logger__.debug("No path mapping was found that matched " + "to URL: " + url);
        throw new InvalidResourceException("No path mapping was found " + "that matched to URL: " + url);
    }
    // Always return true.
    return true;
}

From source file:com.yoho.core.trace.instrument.web.TraceInterceptor.java

private String getFullUrl(HttpServletRequest request) {
    StringBuffer requestURI = request.getRequestURL();
    String queryString = request.getQueryString();
    if (queryString == null) {
        return requestURI.toString();
    } else {//ww  w  .  j  a  va  2s .  co  m
        return requestURI.append('?').append(queryString).toString();
    }
}

From source file:de.yaio.services.metaextract.server.controller.MetaExtractController.java

protected String createRequestLogMessage(HttpServletRequest request) {
    return new StringBuilder("REST Request - ").append("[HTTP METHOD:").append(request.getMethod())
            .append("] [URL:").append(request.getRequestURL()).append("] [REQUEST PARAMETERS:")
            .append(getRequestMap(request)).append("] [REMOTE ADDRESS:").append(request.getRemoteAddr())
            .append("]").toString();
}

From source file:com.aestheticsw.jobkeywords.web.html.JobController.java

/**
 * This exception handler passes the exception message to Thymeleaf, but suppresses the stack
 * trace from the UI.// w  w  w  . j  a  v a2  s .  c o  m
 */
@ExceptionHandler(Throwable.class)
public ModelAndView handleError(HttpServletRequest req, Throwable exception) {
    log.error("Request: " + req.getRequestURL() + " raised " + exception, exception);

    ModelAndView mav = new ModelAndView();
    mav.addObject("message", exception.getMessage());
    mav.addObject("exception", exception);
    mav.addObject("url", req.getRequestURL());
    mav.setViewName("exception");
    return mav;
}

From source file:nl.surfnet.coin.selfservice.filter.ApiOAuthFilter.java

private String getCurrentRequestUrl(HttpServletRequest request) {
    StringBuilder sb = new StringBuilder().append(request.getRequestURL());
    if (!StringUtils.isBlank(request.getQueryString())) {
        sb.append("?").append(request.getQueryString());
    }//from   w  ww .  ja  va  2  s .c  o m
    return sb.toString();
}

From source file:org.n52.restfulwpsproxy.webapp.rest.JobController.java

@RequestMapping(value = "/{jobId:.+}", method = RequestMethod.GET)
public ResponseEntity<StatusInfoWrapperWithOutput> getStatus(@PathVariable("processId") String processId,
        @PathVariable("jobId") String jobId, HttpServletRequest request) {
    StatusInfoDocument statusInfo = client.getStatusInfo(processId, jobId);
    return ResponseEntity.ok(new WPSStatusJsonModule.StatusInfoWrapperWithOutput(
            request.getRequestURL().toString(), statusInfo));
}

From source file:net.ljcomputing.core.controler.GlobalExceptionController.java

/**
 * Handle all data integrity violation exceptions.
 *
 * @param req//from   w w w.  j a va2 s . c  o m
 *            the req
 * @param exception
 *            the exception
 * @return the error info
 */
@Order(Ordered.HIGHEST_PRECEDENCE)
@ExceptionHandler(DataIntegrityViolationException.class)
@ResponseStatus(HttpStatus.CONFLICT)
public @ResponseBody ErrorInfo handleAllDataIntegrityViolationExceptions(HttpServletRequest req,
        Exception exception) {
    logger.error("The data sent for processing had errors {}:", req.getRequestURL().toString(), exception);

    if (exception.getMessage().contains("Unique property")) {
        return new ErrorInfo(getCurrentTimestamp(), HttpStatus.CONFLICT, req.getRequestURL().toString(),
                new Exception("The saved value already exists."));
    }

    return new ErrorInfo(getCurrentTimestamp(), HttpStatus.CONFLICT, req.getRequestURL().toString(), exception);
}