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:org.pentaho.platform.web.http.request.PentahoHttpRequestListener.java

public void requestInitialized(ServletRequestEvent sre) {
    if (!(sre.getServletRequest() instanceof HttpServletRequest)) {
        return;//from w ww. j a  v  a 2 s. c  om
    }

    HttpServletRequest request = (HttpServletRequest) sre.getServletRequest();
    IPentahoSession session = PentahoHttpSessionHelper.getPentahoSession(request);

    if (logger.isTraceEnabled()) {
        logger.trace("binding session " + session + " to request " + sre.getServletRequest());
    }

    PentahoSessionHolder.setSession(PentahoHttpSessionHelper.getPentahoSession(request));
}

From source file:com.krawler.common.listeners.LocaleResolverListener.java

@Override
public void requestInitialized(ServletRequestEvent sre) {
    ServletRequest request = sre.getServletRequest();
    ServletContext context = sre.getServletContext();

    if (request != null && context != null) {
        request.setAttribute(LocaleUtils.LOCALE_RESOLVER_ATTRIBUTE,
                context.getAttribute(LocaleUtils.LOCALE_RESOLVER_NAME));
    } else {//from  ww w .ja  va2s. c  om
        log.debug("Locale resolver cannot be associated with request [request:" + request + ",context:"
                + context + "]");
    }
}

From source file:com.fatwire.gst.web.status.StatusRequestListener.java

public void requestDestroyed(ServletRequestEvent event) {
    if (event.getServletRequest() instanceof HttpServletRequest)
        try {//from   w ww  . ja  v  a2s .  c  o m
            requestCounter.end((HttpServletRequest) event.getServletRequest());
        } catch (Throwable e) {
            log.warn(e.getMessage(), e);
        }

}

From source file:com.fatwire.gst.web.status.StatusRequestListener.java

public void requestInitialized(ServletRequestEvent event) {
    if (event.getServletRequest() instanceof HttpServletRequest)
        try {/*from   w w w .  j a va  2  s.c  o m*/
            requestCounter.start((HttpServletRequest) event.getServletRequest());
        } catch (Throwable e) {
            log.warn(e.getMessage(), e);
        }

}

From source file:org.springframework.web.context.request.RequestContextListener.java

public void requestInitialized(ServletRequestEvent requestEvent) {
    if (!(requestEvent.getServletRequest() instanceof HttpServletRequest)) {
        throw new IllegalArgumentException(
                "Request is not an HttpServletRequest: " + requestEvent.getServletRequest());
    }/*from  ww w  .ja  v a 2  s.  c om*/
    HttpServletRequest request = (HttpServletRequest) requestEvent.getServletRequest();
    ServletRequestAttributes attributes = new ServletRequestAttributes(request);
    request.setAttribute(REQUEST_ATTRIBUTES_ATTRIBUTE, attributes);
    LocaleContextHolder.setLocale(request.getLocale());
    RequestContextHolder.setRequestAttributes(attributes);
    if (logger.isDebugEnabled()) {
        logger.debug("Bound request context to thread: " + request);
    }
}

From source file:ReqListener.java

public void requestInitialized(ServletRequestEvent sre) {

    ServletContext context = sre.getServletContext();
    ServletRequest request = sre.getServletRequest();

    synchronized (context) {
        context.log("Request for "
                + (request instanceof HttpServletRequest ? ((HttpServletRequest) request).getRequestURI()
                        : "Unknown")
                + "; Count=" + ++reqCount);
    }//from ww  w.jav  a 2s. co m

}

From source file:com.ineunet.knife.upload.WebPaths.java

@Override
public void requestInitialized(ServletRequestEvent requestEvent) {
    if (!(requestEvent.getServletRequest() instanceof HttpServletRequest)) {
        throw new IllegalArgumentException(
                "Request is not an HttpServletRequest: " + requestEvent.getServletRequest());
    }/*from   w  ww  . j  a va 2  s . c o  m*/
    HttpServletRequest request = (HttpServletRequest) requestEvent.getServletRequest();
    WebPaths.init(request);
}

From source file:com.krawler.filter.ReuqestListenerForDB.java

@Override
public void requestInitialized(ServletRequestEvent sre) {
    HttpServletRequest request = (HttpServletRequest) sre.getServletRequest();
    String path = request.getRequestURL().toString();
    String subdomain = null;//from   w  w w.  ja  va 2s.c  om
    if ((subdomain = extractSubdomain(path, pattern)) != null) {
        CompanyContextHolder.setCompanySubdomain(subdomain);
    } else if ((subdomain = request.getParameter(COMPANY_PARAM)) != null) {
        CompanyContextHolder.setCompanySubdomain(subdomain.trim());
    } else if ((subdomain = request.getParameter(COMPANY_SUBDOMAIN)) != null) {
        CompanyContextHolder.setCompanySubdomain(subdomain.trim());
    } else if (request.getParameter(COMPANY_ID) != null) {
        CompanyContextHolder.setCompanyID(request.getParameter(COMPANY_ID));
    } else if (request.getParameter(USER_ID) != null) {
        CompanyContextHolder.setUserID(request.getParameter(USER_ID));
    } else if (path.contains("deskeraCRMMOB_V1.jsp") && (subdomain = request.getParameter("d")) != null) {// handle case for iphone user authentication
        CompanyContextHolder.setCompanySubdomain(subdomain.toLowerCase().trim());
    } else {
        clearCompanySubdomain();
    }
    logger.debug("Current subdomain : " + subdomain);
}

From source file:com.inkubator.sms.gateway.util.SpringSecurityContextListenerFix.java

@Override
public void requestInitialized(ServletRequestEvent requestEvent) {
    super.requestInitialized(requestEvent);
    HttpServletRequest request = (HttpServletRequest) requestEvent.getServletRequest();
    HttpSession sesion = request.getSession(false);
    Locale idioma;//from www.  ja  v a2s.  c  o m
    if (sesion != null) {
        //            System.out.println(sesion.getAttribute(HRMConstant.BAHASA_ACTIVE).toString());
        if (sesion.getAttribute(SMSGATEWAY.BAHASA_ACTIVE) != null) {
            idioma = new Locale(sesion.getAttribute(SMSGATEWAY.BAHASA_ACTIVE).toString());
        } else {
            idioma = new Locale("in");
        }
        LocaleContextHolder.setLocale(idioma);
    } else {
        idioma = new Locale("in");
        LocaleContextHolder.setLocale(idioma);
    }
}

From source file:org.springframework.web.context.request.RequestContextListener.java

public void requestDestroyed(ServletRequestEvent requestEvent) {
    ServletRequestAttributes attributes = (ServletRequestAttributes) requestEvent.getServletRequest()
            .getAttribute(REQUEST_ATTRIBUTES_ATTRIBUTE);
    ServletRequestAttributes threadAttributes = (ServletRequestAttributes) RequestContextHolder
            .getRequestAttributes();//w  w  w.  j a va2  s. com
    if (threadAttributes != null) {
        // We're assumably within the original request thread...
        if (attributes == null) {
            attributes = threadAttributes;
        }
        RequestContextHolder.setRequestAttributes(null);
        LocaleContextHolder.setLocale(null);
    }
    if (attributes != null) {
        attributes.requestCompleted();
        if (logger.isDebugEnabled()) {
            logger.debug("Cleared thread-bound request context: " + requestEvent.getServletRequest());
        }
    }
}