Lion
Lion

Reputation: 21

how to get real httpServletRequest and response as servlet programming

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?

Upvotes: 2

Views: 2900

Answers (4)

Marks
Marks

Reputation: 347

you can get the httpServletRequest by this:

request.args.get(ServletWrapper.SERVLET_REQ);   //get HttpServletRequest
request.args.get(ServletWrapper.SERVLET_RES);   //get httpServletResponse

Upvotes: 3

Damo
Damo

Reputation: 11550

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.

Upvotes: 2

alfonso.kim
alfonso.kim

Reputation: 2900

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.

Upvotes: 0

niels
niels

Reputation: 7309

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.

Upvotes: 1

Related Questions