The setMaxAge method sets the _________ of a cookie in seconds.
- age
- duration
- expiration time
- size
The setMaxAge method sets the expiration time of a cookie in seconds, specifying how long the cookie should persist.
Servlet initialization parameters are primarily used for ___________ configuration.
- application
- deployment
- environment
- runtime
Servlet initialization parameters are primarily used for application configuration.
Which method is used to send an error status code along with a custom message in the response header?
- sendError()
- sendStatusCode()
- setErrorCode()
- setErrorMessage()
The sendError() method is used to send an error status code along with a custom message in the response header.
Can a servlet's destroy() method be overridden? If yes, what should be considered?
- It depends on the servlet container being used.
- No, the destroy() method cannot be overridden.
- Yes, but it is not advisable to override it.
- Yes, it can be overridden, and it is recommended to do so.
Yes, a servlet's destroy() method can be overridden, but it is recommended to do so carefully, ensuring that necessary cleanup operations are performed. Considerations should be given to resource release and proper handling of exceptions in the overridden method.
A web application needs to remember user preferences across sessions. Which approach using cookies is most suitable?
- HttpOnly Cookies
- Persistent Cookies
- Secure Cookies
- Session Cookies
Persistent Cookies are suitable for remembering user preferences across sessions as they persist even after the user closes the browser.
ServletContext is used for sharing information between:
- Browser and Server
- Client and Server
- JSP and Servlet
- Web components
ServletContext is used for sharing information between web components within the same web application, like servlets, JSP pages, and other resources.
How are HTTP session cookies handled in servlets?
- Cookies are handled automatically by servlet containers.
- Cookies are managed using the Cookie class.
- Cookies are not supported in servlets.
- Cookies must be handled manually in the doGet() method.
In servlets, HTTP session cookies are typically managed using the Cookie class, allowing developers to handle cookie creation, retrieval, and manipulation programmatically.
The __________ method of the ServletContext interface is used to retrieve context parameters.
- contextParam()
- getContextParameter()
- getInitParameter()
- retrieveParameter()
The getInitParameter() method of the ServletContext interface is used to retrieve context parameters associated with the servlet's context.
Session tracking using ________ involves storing a small piece of information on the client's browser.
- Cookies
- Hidden Fields
- Session ID
- URL Rewriting
Session tracking using Cookies involves storing a small piece of information on the client's browser.
To access the MIME type of a file, use the __________ method of ServletContext.
- analyzeMimeType()
- fetchMimeType()
- getMimeType()
- retrieveMimeType()
To access the MIME type of a file, use the getMimeType() method of ServletContext.