Differences between revisions 4 and 5
Revision 4 as of 2008-11-09 16:02:52
Size: 992
Comment:
Revision 5 as of 2009-09-20 23:20:47
Size: 994
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
The underlying HTTP servlet mechanics are available via the [http://tapestry.apache.org/tapestry5/tapestry-core/apidocs/org/apache/tapestry/services/RequestGlobals.html RequestGlobals] service. The underlying HTTP servlet mechanics are available via the [[http://tapestry.apache.org/tapestry5/tapestry-core/apidocs/org/apache/tapestry/services/RequestGlobals.html|RequestGlobals]] service.

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)