The method ___________ is used to read a single initialization parameter in the servlet.
- fetchParameter()
- getInitParam()
- getInitParameter()
- readInitParameter()
The method getInitParameter() is used to read a single initialization parameter in the servlet.
To set the character encoding for the response body, use the __________ method of HttpServletResponse.
- setCharacterEncoding()
- setContentType()
- setEncoding()
- setResponseEncoding()
The setCharacterEncoding() method of HttpServletResponse is used to set the character encoding for the response body.
The __________ method of HttpServletResponse causes the browser to request a new URL.
- forward()
- include()
- refresh()
- sendRedirect()
The sendRedirect() method of HttpServletResponse causes the browser to request a new URL.
ServletConfig's getServletName() method returns the __________ of the servlet.
- ID
- alias
- handle
- name
ServletConfig's getServletName() method returns the name of the servlet.
To delete a cookie, the servlet should set its _________ to a past date.
- creation time
- domain
- expiration date
- path
To delete a cookie, the servlet should set its expiration date to a past date, making it immediately invalid.
Which technology is primarily used for writing business logic in a web application?
- CSS
- HTML
- JSP
- Servlets
Servlets are primarily used for writing business logic in a web application.
Cookies used for tracking user sessions are typically called _________ cookies.
- Persistent
- Secure
- Session
- Tracking
Cookies used for tracking user sessions are typically called Session cookies.
In which method of a servlet are most of the resources like threads, database connections, etc., released?
- destroy()
- doGet()
- init()
- service()
The destroy() method is called when a servlet is being removed from service, and it is used to release resources like threads and database connections.
To set multiple values for the same header, use the __________ method in HttpServletResponse.
- addHeader()
- appendHeader()
- setHeader()
- setMultipleValuesHeader()
The addHeader() method in HttpServletResponse is used to add multiple values for the same header, allowing for flexibility in handling headers with multiple values.
A servlet needs to read its own initialization parameters and also share a database connection pool. Which combination of objects should it use?
- getInitParameter() and ServletContext
- getServletConfig() and getServletContext()
- getServletContext() and getInitParameter()
- getServletContext() and getInitParameter()
To read its own initialization parameters, a servlet should use getInitParameter(). To share a database connection pool, it should use the ServletContext, which is accessible via getServletContext().