how to get real httpServletRequest and response as servlet programming
how to get real httpServletRequest and response as servlet programmin开发者_如何转开发g
My project load a jar need use this parameter.
but perhaps can't get it in play!
how to resove this?
you can get the httpServletRequest
by this:
request.args.get(ServletWrapper.SERVLET_REQ); //get HttpServletRequest
request.args.get(ServletWrapper.SERVLET_RES); //get httpServletResponse
If you have a JAR that depends on the httpServletRequest
then you can look at loading it in a standard HTTP Servlet Filter and deploying Play via the play war
command. This will let you specify your filter in the web.xml
. From there you can look at ways of interacting with Play (eg. passing values retrieved from the operations of the jar).
What does this jar do?
I've done exactly this sort of thing with the Jespa library that provides NTLM. I have a filter that intercepts the HTTP request. Does it's Jespa magic and passes the results to Play via HTTP Headers.
Have a good read of the Play Deployment Options in the docs - especially the custom web.xml section.
Short answer: You can't do this.
Long answer: If it is a good written library it doesn't depends to hard on the servlet engine so you can write some code which makes the functionality work in play. Specially it should be stateless! If it is a closed source jar, I think you have no chance.
You can read this blog post from the Play! Framework author (search for Why there is no servlets in Play). He answers your questions in a very clear and convincing way.
精彩评论