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.

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.

How does session tracking differ between stateless and stateful protocols?

  • Stateful: Lightweight
  • Stateful: Stores client state
  • Stateless: No memory of previous requests
  • Stateless: Uses cookies
Stateless protocols, like HTTP, have no memory of previous requests, while stateful protocols, like HTTPS, store client state, allowing continuity across multiple requests.

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.