The __________ method of AsyncContext is used to dispatch the request to another servlet.

  • dispatch()
  • forward()
  • include()
  • sendRedirect()
The dispatch() method of AsyncContext is used to dispatch the request to another servlet during asynchronous processing.

What is the primary use of RequestDispatcher in servlets?

  • Forwarding requests
  • Initializing servlets
  • Processing GET requests
  • Sending redirect responses
The primary use of RequestDispatcher in servlets is for forwarding requests to another resource (servlet, JSP, or HTML) on the server.

What method is used to complete the asynchronous process and send a response?

  • complete()
  • finalize()
  • finish()
  • sendResponse()
The complete() method is used to complete the asynchronous process and send a response in asynchronous servlets.

How can a servlet determine if an incoming request supports asynchronous processing?

  • canAsyncProcess()
  • isAsyncRequest()
  • isAsyncSupported()
  • supportsAsync()
The isAsyncSupported() method is used by a servlet to determine if an incoming request supports asynchronous processing.

For file download, what Content-Type should be set in the servlet response?

  • application/json
  • application/octet-stream
  • image/png
  • text/html
For file download, the Content-Type in the servlet response should be set to application/octet-stream to indicate that the response contains binary data without any specific format.

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.