Reputation: 8697
I would like to receive parameters via plain text and http requests. The data is coming in, but I'm stuck with processing it correctly.
Here is some pseudocode of what I would like to achieve:
// ...
String input = in.readLine();
if (HttpHelperClass.isValidHttpRequest(input)) {
// process http request
MyHttpRequest = HttpHelperClass.processInput(input);
if (MyHttpRequest.isMethod(HTTP_METHOD_GET)) {
String name = MyHttpRequest.getParameter('name');
String response = HttpHelperClass.buildResponse("Hello " + name, 200);
out.println(response);
}
} else {
// process plain text
}
Does Java have something like this out of the box or can anyone recommend anything?
Thanks in advance!
Upvotes: 0
Views: 254
Reputation: 5383
Your best bet is to use UrlQuerySanitizer
. Use this to parse the URL and then call getValue("param-name")
to get the desired parameter values.
Upvotes: 1