Example usage for javax.servlet ServletRequestEvent getServletRequest

List of usage examples for javax.servlet ServletRequestEvent getServletRequest

Introduction

In this page you can find the example usage for javax.servlet ServletRequestEvent getServletRequest.

Prototype

public ServletRequest getServletRequest() 

Source Link

Document

Returns the ServletRequest that is changing.

Usage

From source file:nl.surfnet.coin.shared.log.ApiCallLogContextListener.java

@Override
public void requestInitialized(ServletRequestEvent requestEvent) {
    ApiCallLog apiCallLog = new ApiCallLog();
    HttpServletRequest request = (HttpServletRequest) requestEvent.getServletRequest();
    String queryString = request.getQueryString();
    StringBuffer requestURL = request.getRequestURL();
    if (StringUtils.hasText(queryString)) {
        requestURL.append("?").append(queryString);
    }/*  w  w  w .j  av  a2s . c  o m*/
    try {
        apiCallLog.setResourceUrl(URLEncoder.encode(requestURL.toString(), "utf-8"));
        apiCallLog.setIpAddress(request.getRemoteAddr());
    } catch (UnsupportedEncodingException e) {
        // will never happen as utf-8 is the encoding
    }
    apiCallLogHolder.set(apiCallLog);
}

From source file:com.mtgi.analytics.servlet.BehaviorTrackingListener.java

public void requestDestroyed(ServletRequestEvent event) {
    if (adapters != null) {
        ServletRequest request = event.getServletRequest();
        BehaviorEvent[] events = (BehaviorEvent[]) request.getAttribute(ATT_EVENTS);
        if (events == null) {
            log.error("no behavior events stored in the current request ("
                    + ((HttpServletRequest) request).getRequestURI());
        } else {//from w w  w.jav  a  2  s .  com
            request.removeAttribute(ATT_EVENTS);
            for (int i = adapters.length - 1; i >= 0; --i)
                try {
                    adapters[i].stop(events[i]);
                } catch (Exception e) {
                    log.error("Error stopping http event", e);
                }
        }
    }
}

From source file:org.pentaho.platform.web.http.request.PentahoHttpRequestListener.java

public void requestDestroyed(ServletRequestEvent sre) {
    if (logger.isTraceEnabled()) {
        logger.trace("unbinding session " + PentahoSessionHolder.getSession() + " from request: "
                + sre.getServletRequest());
    }/*w w w.j  a  va  2 s  .  c  o m*/
    PentahoSessionHolder.removeSession();
}

From source file:org.mayocat.context.RequestContextInitializer.java

private boolean isSecure(ServletRequestEvent event) {
    return event.getServletRequest().isSecure();
}

From source file:org.mayocat.context.RequestContextInitializer.java

private String getHost(ServletRequestEvent event) {
    return event.getServletRequest().getServerName();
}

From source file:org.mayocat.context.RequestContextInitializer.java

private String getPath(ServletRequestEvent event) {
    return ((HttpServletRequest) event.getServletRequest()).getPathInfo();
}

From source file:org.mayocat.context.RequestContextInitializer.java

private String getRequestURI(ServletRequestEvent event) {
    return ((HttpServletRequest) event.getServletRequest()).getRequestURI();
}

From source file:org.mayocat.context.RequestContextInitializer.java

private String getUserAgent(ServletRequestEvent event) {
    return ((HttpServletRequest) event.getServletRequest()).getHeader("User-Agent");
}

From source file:org.mayocat.context.RequestContextInitializer.java

private String getHeaderValue(ServletRequestEvent event, String headerName) {
    return ((HttpServletRequest) event.getServletRequest()).getHeader(headerName);
}

From source file:org.mayocat.context.RequestContextInitializer.java

public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
    if (isStaticPath(((HttpServletRequest) servletRequestEvent.getServletRequest()).getRequestURI())) {
        return;/* w w w.j  av  a 2  s  . com*/
    }

    ((ThreadLocalWebContext) this.context).setContext(null);
}