In a servlet, to get an array of all the values of a multi-valued parameter, use the __________ method.
- getArrayValues()
- getMultiValuedParameter()
- getParameterValues()
- retrieveParameterArray()
The getParameterValues() method in a servlet is used to get an array of all the values of a multi-valued parameter.
A developer needs to implement complex business logic with minimal HTML. Should they choose Servlet or JSP?
- Both
- JSP
- None of the above
- Servlet
When implementing complex business logic with minimal HTML, Servlets are more suitable as they provide better control over the business logic, separating it from the presentation layer. JSP is better for the view layer and is commonly used for creating dynamic web pages with embedded Java code.
A ________ request can be cached by the browser, whereas a ________ request cannot.
- GET; POST
- GET; PUT
- POST; DELETE
- POST; PUT
A GET request can be cached by the browser, whereas a POST request cannot be cached.
What object is primarily used to read form data in a servlet?
- FormReader
- HttpRequest
- HttpServletRequest
- ServletRequest
The HttpServletRequest object is primarily used to read form data in a servlet.
When handling file uploads in a servlet, the __________ utility class from Apache Commons FileUpload can be used.
- FileParser
- FileReader
- FileUpload
- FileWriter
When handling file uploads in a servlet, the FileUpload utility class from Apache Commons FileUpload is commonly used for parsing and processing multipart/form-data requests, including file uploads.
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.
What changes are required in a servlet to handle multipart/form-data requests?
- Implement a custom parsing algorithm
- Implement doPost method
- No changes needed
- Set content type to multipart/form-data
To handle multipart/form-data requests, set the content type to multipart/form-data in the servlet. This allows the servlet to recognize and process multipart requests correctly, especially when dealing with file uploads or other complex data structures.
The __________ method invalidates the current session and removes its binding from the context.
- destroySession()
- endSession()
- invalidate()
- removeSession()
The invalidate() method invalidates the current session and removes its binding from the context.
A servlet's URL pattern is specified in the __________ element in the web application's deployment descriptor.
- servlet-mapping
- servlet-url
- url-mapping
- url-pattern
The url-pattern element in the web application's deployment descriptor is used to specify a servlet's URL pattern, mapping it to a particular servlet.
In servlets, thread-safety issues are often handled in the __________ method.
- destroy()
- doPost()
- init()
- service()
In servlets, thread-safety issues are often handled in the init() method.