opensas
opensas

Reputation: 63415

how to get a the value of an http post as a whole? parsing restful post

Is it my ideea or in rest-web services a post comes "with no name", so say something...

I mean, is the post the whole body, minus headers???

so, how can I parse such a post message with java?

do I have to use

HttpServletRequest.getInputStream?

http://www.softlab.ntua.gr/facilities/documentation/unix/java/servlet2.2/javax/servlet/http/HttpServletResponse.html

any useful example?

and how do I make such a call? I mean, posting value in the body and not in a specific parameter...

thanks a lot

Upvotes: 0

Views: 532

Answers (2)

laz
laz

Reputation: 28638

The server side code would look like the following:

StringBuilder input = new StringBuilder();
BufferedReader reader = request.getReader();
String line = reader.readLine();
while (line != null) {
    input.append(line);
    line = reader.readLine();
}

Where request is the HttpServletRequest. For testing this from the client side, you can use Poster with Firefox.

Upvotes: 1

Byron Whitlock
Byron Whitlock

Reputation: 53851

Fiddler is really useful for this sort of thing. It is acts as a standard http proxy on your local machine. You can view the post body and headers etc in it's interface. You just have to tell your code to use an HTTP proxy (usually just 1 or 2 lines of )

Upvotes: 1

Related Questions