0

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!

1 Answer 1

1

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.

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

1 Comment

Thanks for your answer, but I think the UrlQuerySanitizer only covers URLs and their GET parameters. I need to process POST as well.

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.