How can I get POST data from Jetty AbstractHandler descriptor method?

Searched SO quite a bit but didn't see any posts that seemed to fit my particular situation / question.

Using Jetty, I have a Handler class that extends org.eclipse.jetty.server.handler.AbstractHandler.

The descriptor method looks like this:

    public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
                       throws IOException, ServletException {


I need to grab the POST data sent in a request like this:

curl -H "Content-Type: application/json" -d '{"url":""}' http://localhost:8080/

Basically, I am sending a POST request to my localhost using a JSON dictionary with the key "url". How can I get the POST data?


source to share

1 answer

Use the standard servlet functions available with a parameter HttpServletRequest

in Handler.handle()



has 2 methods that have access to the request body.

Then just use any of these 2 using standard Java IO methods.



All Articles