Documentation

You are viewing the documentation for the 2.0.x release series. The latest stable release series is 3.0.x.

§Intercepting requests

§Overriding onRequest

One important aspect of the GlobalSettings class is that it provides a way to intercept requests and execute business logic before a request is dispatched to an action.

For example:

import play.*;

public class Global extends GlobalSettings {

@Override
public Action onRequest(Request request, Method actionMethod) {
   System.out.println("before each request..." + request.toString());
   return super.onRequest(request, actionMethod);
}

}

It’s also possible to intercept a specific action method. This can be achieved via Action composition.

Next: Testing your application


Found an error in this documentation? The source code for this page can be found here. After reading the documentation guidelines, please feel free to contribute a pull request. Have questions or advice to share? Go to our community forums to start a conversation with the community.