how to get real httpServletRequest and response as

2019-07-07 19:04发布

how to get real httpServletRequest and response as servlet programming

My project load a jar need use this parameter.

but perhaps can't get it in play!

how to resove this?

4条回答
聊天终结者
2楼-- · 2019-07-07 19:35

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.

查看更多
疯言疯语
3楼-- · 2019-07-07 19:40

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.

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-07-07 19:42

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.

查看更多
小情绪 Triste *
5楼-- · 2019-07-07 19:44

you can get the httpServletRequest by this:

request.args.get(ServletWrapper.SERVLET_REQ);   //get HttpServletRequest
request.args.get(ServletWrapper.SERVLET_RES);   //get httpServletResponse
查看更多
登录 后发表回答