Frameworks such as Spring Boot (its own course, DF-P77) decode requests and turn exceptions into responses for you, but the rules they apply are plain Java, and you still decide them. This lesson writes those rules directly.
A query string arrives percent-encoded: + is a space and %C3%A9 is two bytes that make one é. A record's compact constructor can normalize and validate its fields, so an invalid request object can never exist. Exceptions carry meaning: a missing order is 404, bad input is 400, a state conflict is 409, and anything unexpected is a 500 that must not leak its message. And a POST with an idempotency key can be retried safely, as long as bodies are compared with equals rather than ==.
Each task is a method you could drop into a framework's controller or filter.
A compact constructor normalizes before the fields are set.