java - How can I retrieve POST data from a Jetty AbstractHandler handle() method? -
searched quite bit, didn't see posts seemed match particular situation/question.
using jetty, have handler class extending org.eclipse.jetty.server.handler.abstracthandler.
the handle method follows:
@override public void handle(string target, request baserequest, httpservletrequest request, httpservletresponse response) throws ioexception, servletexception {
i need grab post data sent in request, if this:
curl -h "content-type: application/json" -d '{"url":"http://www.example.com"}' http://localhost:8080/
basically, i'm sending post request localhost json dictionary keyed on 'url'. how can retrieve post data?
use standard servlet features available httpservletrequest
parameter in handler.handle()
method.
the httpservletrequest
has 2 methods have access request body.
- for text content, use
httpservletrequest.getreader()
- for binary content, use
httpservletrequest.getinputstream()
then use either of 2 using standard java io techniques.
Comments
Post a Comment