Which HTTP status code is typically sent by an HTTP servlet to indicate a successful response?
- 200 OK
- 302 Found
- 404 Not Found
- 500 Internal Server Error
The HTTP status code 200 OK is typically sent by an HTTP servlet to indicate a successful response. This status code signals that the request has been successfully processed, and the server is returning the requested resource.
To retrieve an AsyncContext object in a servlet, you use the __________ method of the HttpServletRequest.
- getAsyncContext()
- initAsync()
- retrieveAsync()
- startAsync()
To retrieve an AsyncContext object in a servlet, you use the getAsyncContext() method of the HttpServletRequest.
In asynchronous servlets, the __________ method of AsyncContext sends the response to the client.
- complete()
- finish()
- getResponseWriter()
- sendResponse()
In asynchronous servlets, the complete() method of AsyncContext is used to send the response to the client.
To add an AsyncListener to an AsyncContext, use the __________ method.
- addAsyncListener()
- addListener()
- attachListener()
- registerListener()
To add an AsyncListener to an AsyncContext, use the addAsyncListener() method.
The __________ method of AsyncContext allows for manually controlling the timeout of an asynchronous operation.
- adjustTimeout()
- controlTimeout()
- setAsyncTimeout()
- setTimeout()
The setAsyncTimeout() method of AsyncContext allows for manually controlling the timeout of an asynchronous operation.
To handle multiple file uploads, a servlet may use the __________ API.
- Java Authentication and Authorization Service (JAAS)
- Java Naming and Directory Interface (JNDI)
- JavaBeans Activation Framework (JAF)
- JavaMail
To handle multiple file uploads, a servlet may use the JavaBeans Activation Framework (JAF) API to work with various types of data, including files.
How can a servlet handle multipart/form-data requests for file uploading?
- request.getAttribute()
- request.getInputStream()
- request.getParameter()
- request.getPart()
To handle multipart/form-data requests for file uploading in servlets, the request.getPart() method is used to retrieve the uploaded file data.
In servlets, what is used to facilitate the reading of file data sent by a client?
- BufferedReader
- FileInputStream
- FileReader
- InputStreamReader
In servlets, the InputStream obtained using request.getInputStream() is commonly used to facilitate the reading of file data sent by a client.
What must be done to ensure the safe and correct download of files with different character encodings?
- Encode files as ASCII
- Set the character encoding in the response header
- Use a fixed character encoding
- Use the default character encoding
To ensure the safe and correct download of files with different character encodings, set the character encoding in the response header using response.setCharacterEncoding().
What are the security concerns to consider while implementing file upload in servlets?
- All of the above
- Checking file size
- Securing file storage location
- Validating file types
When implementing file upload in servlets, it's crucial to consider security concerns such as validating file types, checking file size, and securing the file storage location to prevent vulnerabilities.