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.

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.

To handle JSON data in a POST request, a servlet may need to parse the request body using a _________.

  • HttpServletRequest
  • HttpServletResponse
  • JsonObject
  • JsonReader
In a POST request, to handle JSON data, a servlet may need to parse the request body using a JsonObject.

To prevent character encoding issues when reading form data, the method __________ should be called before any getParameter methods.

  • encodeCharacters
  • handleEncoding
  • resolveCharacterIssues
  • setCharacterEncoding
To prevent character encoding issues when reading form data, the setCharacterEncoding method should be called before any getParameter methods. This ensures correct interpretation of characters in the form data.

The method __________ of the HttpServletRequest is used to read binary data from a form input.

  • getBinaryData()
  • getInputStream()
  • readBinaryData()
  • readFormData()
The getInputStream() method of the HttpServletRequest is used to read binary data from a form input.

When using RequestDispatcher's forward method, changes to the response _________ affect the final output.

  • always
  • may
  • will
  • will not
When using RequestDispatcher's forward method, changes to the response will not affect the final output, as the forward method transfers control without changing the response.