A servlet needs to load database settings at startup. How should these settings be passed to the servlet?
- Hardcode the settings in the servlet code
- Store settings in a local properties file
- Use ServletContext parameters
- Use request parameters
The recommended approach is to use ServletContext parameters to pass settings at servlet startup, as they can be accessed by all servlets within the same web application. Hardcoding or using request parameters may not be suitable for initialization settings.
Loading...
Related Quiz
- Memory leaks in Java often occur due to __________ objects not being released properly.
- How does ServletRequestAttributeListener differ from ServletRequestListener in its functionality?
- The method __________ is called to start asynchronous processing in a servlet.
- A filter can alter the header information of a request or response by modifying the _______.
- In the context of servlets, what is a key difference between HTTP and WebSocket protocols?