0

How do I access the request object inside my java controller in the play framework?

The Scala tutorial-page references some sort of "request" object, but I don't see how to access that in the Java tutorial-page.

I'm using Play Framework 2.5

2 Answers 2

1

The answer is really clear and straightforward:

When you call request() you access to the requests object, like headers and body, example request().body()

Much more here: https://www.playframework.com/documentation/2.5.x/JavaBodyParsers

Sign up to request clarification or add additional context in comments.

2 Comments

i mean, i like your answer (it answers the question, even with an example!) - but it is passive aggressive, and thus rude. The page you link is riddled with facts, and it, to me, when i search for "request" using the play search - it is not obvious where to look. I'm not sure how you found that page, but "body parser" is not something intuitive for "request". This isn't your fault, you didn't write the page - but, in making your answer belittling you impact the spread of knowledge (asking is important to transfer too), and also, de-facto defend this terrible documentation.
@bharal sorry, i not meant to be aggressive.
0

Just add explicitly type: Action { request: Request[_] => ... }

1 Comment

Please use proper formatting and collaborate your answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.