1Z0-900 · Question #20
Given the code fragment: mapping?
The correct answer is C. The container throws an error at startup. Note: The code fragment appears to be missing from this question, but based on the answer choices and correct answer, this is a classic duplicate URL-pattern mapping scenario in Java Servlet configuration. Option C is correct because when two or more servlets are mapped to the…
Question
Given the code fragment:
mapping?
Exhibit
Options
- AthirdServlet handles the request.
- BfirstServlet handles the request.
- CThe container throws an error at startup.
- DsecondServlet handles the request.
How the community answered
(26 responses)- A4% (1)
- B12% (3)
- C62% (16)
- D23% (6)
Explanation
Note: The code fragment appears to be missing from this question, but based on the answer choices and correct answer, this is a classic duplicate URL-pattern mapping scenario in Java Servlet configuration.
Option C is correct because when two or more servlets are mapped to the exact same URL pattern (e.g., /path mapped to both firstServlet and secondServlet) in web.xml or via annotations, the servlet container cannot resolve the ambiguity and throws a deployment/startup error - the application never becomes available.
Options A, B, and D are wrong for the same reason: none of the three servlets ever gets a chance to handle anything, because the container fails before any request is processed. There is no priority-based fallback or "last one wins" behavior for conflicting exact mappings.
Memory tip: Think of it as a traffic intersection with two conflicting stop signs pointing opposite directions - the city (container) refuses to open the road (deploy the app) rather than guessing which rule to obey. Conflicts = startup failure, not runtime resolution.
Topics
Community Discussion
No community discussion yet for this question.
