What does idempotent mean in HTTP?
Strong answer
An operation is idempotent when repeating the same request has the same intended server-side effect as making it once. PUT and DELETE are designed to be idempotent, while POST is not inherently so.
Understand HTTP semantics, REST constraints, status codes, idempotency, and the servlet request lifecycle.
Web fundamentals · protocols
Use the strong answer as your reference, explain it aloud in your own words, then choose how soon you want to review it again.
Interview prompt
Strong answer
HTTP is a request-response protocol with methods, status codes, headers, and representations. REST APIs should make resource semantics and idempotency clear. A servlet container manages the lifecycle around request handling; Spring MVC builds higher-level abstractions over the same web fundamentals.
Key points
Interviewer looks for
Describe the HTTP behavior a client can rely on, including retries, caching, errors, and idempotency.
Java example
1GET /api/users?page=0&size=20
2
3HTTP/1.1 200 OK
4Content-Type: application/json
5
6{"items": [], "page": 0, "size": 20}Topic interview questions
These questions are tied to this lesson. Read each question aloud, then compare your explanation with the strong answer.
Strong answer
An operation is idempotent when repeating the same request has the same intended server-side effect as making it once. PUT and DELETE are designed to be idempotent, while POST is not inherently so.
Strong answer
Use 2xx for success, 3xx for redirects or cache revalidation, 4xx for client or authorization problems, and 5xx for server-side failures. The body should provide stable, useful error details without leaking internals.
Strong answer
The container loads and instantiates a servlet, calls init, invokes service for requests, and eventually calls destroy. A servlet instance may handle concurrent requests, so mutable instance fields need careful synchronization.
Strong answer
Stable resource semantics, clear status codes, validation, authentication rules, pagination, consistent errors, caching behavior, and documented idempotency make an API predictable and safe to integrate.
Strong answer
GET is intended to retrieve a representation without changing server state, which allows browsers, crawlers, caches, and clients to retry it more freely. Side effects on GET create surprising and unsafe behavior.
How well do you know this?
Your review choice is saved locally and synced to your learner profile when signed in.