How do you handle an unchecked exception in a servlet?
- Configure error-page in web.xml
- Log the exception using a logging framework
- Throw ServletException
- Use a try-catch block in doGet()
Configuring an error-page in the web.xml file is a common practice to handle unchecked exceptions in a servlet. It allows you to specify an error page that should be displayed in case of an exception.
Loading...
Related Quiz
- What role do servlets play in handling controller logic in MVC frameworks?
- An online content platform uses caching to improve user experience. However, users in different regions report varying latency. What caching approach can be adopted to optimize for all users?
- Filters are configured in the __________ file of a web application.
- Can a filter modify the request and response objects?
- The listener interface _________ is used to listen for request attribute changes.