Tapestry encapsulates the HTTP servlet request, response and session, and you should not normally need to access them directly. However, sometimes it is necessary. For example, Acegi Security stores exception messages in the HttpSession.

The underlying HTTP servlet mechanics are available via the RequestGlobals service.

Example

    @Inject
    private RequestGlobals requestGlobals;

    public void onActivate(Object context) {
        HttpSession session = requestGlobals.getHTTPServletRequest().getSession();
        ...
    }

/!\ You need the servlet-api.jar in your classpath (dependency not included with tapestry quickstart).

Alternatively, you can inject the HttpServletRequest directly (at least in 5.0.13):

    @Inject
    private HttpServletRequest _request;

RequestGlobals is not accessible inside of AppModule.

Tapestry5ObtainingHttpServletRequest (last edited 2009-09-20 23:20:47 by localhost)