Java Code Examples for javax.servlet.ServletRequestEvent#getServletContext()

The following examples show how to use javax.servlet.ServletRequestEvent#getServletContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestContextListener.java    From onboard with Apache License 2.0 5 votes vote down vote up
@Override
public void requestInitialized(ServletRequestEvent requestEvent) {
    if (!(requestEvent.getServletRequest() instanceof HttpServletRequest)) {
        logger.debug("error type: " + requestEvent.getServletRequest().getClass().getName());
        throw new IllegalArgumentException("Request is not an HttpServletRequest: " + requestEvent.getServletContext());
    }

    HttpServletRequest request = (HttpServletRequest) requestEvent.getServletRequest();
    GlobalServiceImpl.setUpHttpSession(request);
}
 
Example 2
Source File: RequestListener.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public void requestDestroyed(ServletRequestEvent event) {
    HttpServletRequest request = (HttpServletRequest)event.getServletRequest();
    if (!request.getServletPath().equals("/counter")) {
        ServletContext context = event.getServletContext();
        context.setAttribute("counter", (int)context.getAttribute("counter") + 1);
    }
}
 
Example 3
Source File: WeldInitListener.java    From piranha with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void requestInitialized(ServletRequestEvent sre) {
    super.requestInitialized(new ServletRequestEvent(
        sre.getServletContext(), 
        new WeldHttpServletRequest((HttpServletRequest)sre.getServletRequest())));
}