For your purposes, Play is the wrong place to be. Play is designed to be able to run outside of Servlet containers, and therefore implements an API for HTTP requests that does not conform at all to the Servlet API.
You have two options:
Write your own function that converts a
play.api.mvc.Request
to your own implementation ofjavax.servlet.http.HttpServletRequest
. AlthoughHttpServletRequest
is quite a big interface with dependencies on even more big classes, the information contained in the PlayRequest
should be enough to construct anHttpServletRequest
. Depending on your use you might leave some or most methods unimplemented to reduce the effort. Check out this class as an example.If you run your Play 2 application from a Servlet and your method allows, you can write your own Servlet application that runs in front of the Play application. It would then call the methods with the Servlet API you need when required, and forwards request to the Play 2 application when it is not needed.
These are both quite hacky but might be acceptable for a single use case. If you need integration with Servlet APIs or depend on a lot of other code that does, you really need to ask yourself whether Play 2 is the right choice. Play 2 can support any Java EE technology, but the Servlet API specifically is something that it does not support well. If you want to use the Servlet API from a modern Scala HTTP framework, you might want to look at Spray and its servlet support.