Ron McLeod wrote:If your headers are in a map, you could use a ResponseBuilder, iterate through the map entries, and build them in to your response header-by-header.
Mike. J. Thompson wrote:When a Scanner throws an Exception it does not remove the token that caused the Exception from its input. If nextInt throws an exception then repeated calls to nextInt will also throw an Exception. It won't block waiting for more input because it already has input.
You need to clear the invalid token from the input by calling next() in the catch block.