Which of the following is used to specify a servlet's name in the deployment descriptor?

The element in the web.xml file is used to specify the name of a servlet. This name is then referenced in various configurations within the deployment descriptor and is essential for identifying and managing the servlet within the web application.

For efficient handling of large file uploads in a servlet, one should implement __________ instead of using standard getParameter methods.

  • FileStreamReader
  • HttpServletRequest
  • InputStream
  • MultipartRequest
For efficient handling of large file uploads in a servlet, one should implement MultipartRequest instead of using standard getParameter methods for better control and performance in processing multipart/form-data requests.

The setMaxAge method sets the _________ of a cookie in seconds.

  • age
  • duration
  • expiration time
  • size
The setMaxAge method sets the expiration time of a cookie in seconds, specifying how long the cookie should persist.

Servlet initialization parameters are primarily used for ___________ configuration.

  • application
  • deployment
  • environment
  • runtime
Servlet initialization parameters are primarily used for application configuration.

Which method is used to send an error status code along with a custom message in the response header?

  • sendError()
  • sendStatusCode()
  • setErrorCode()
  • setErrorMessage()
The sendError() method is used to send an error status code along with a custom message in the response header.

Can a servlet's destroy() method be overridden? If yes, what should be considered?

  • It depends on the servlet container being used.
  • No, the destroy() method cannot be overridden.
  • Yes, but it is not advisable to override it.
  • Yes, it can be overridden, and it is recommended to do so.
Yes, a servlet's destroy() method can be overridden, but it is recommended to do so carefully, ensuring that necessary cleanup operations are performed. Considerations should be given to resource release and proper handling of exceptions in the overridden method.

A web application needs to remember user preferences across sessions. Which approach using cookies is most suitable?

  • HttpOnly Cookies
  • Persistent Cookies
  • Secure Cookies
  • Session Cookies
Persistent Cookies are suitable for remembering user preferences across sessions as they persist even after the user closes the browser.

ServletContext is used for sharing information between:

  • Browser and Server
  • Client and Server
  • JSP and Servlet
  • Web components
ServletContext is used for sharing information between web components within the same web application, like servlets, JSP pages, and other resources.

For optimizing a web application with heavy presentation logic, which technology is more suitable?

  • Both
  • JSP
  • None of the above
  • Servlet
For optimizing a web application with heavy presentation logic, JSP (JavaServer Pages) is more suitable. JSP is specifically designed for creating dynamic web pages with a focus on presentation logic, making it easier to manage and optimize the presentation layer of a web application.

What is the primary purpose of cookies in web applications?

  • To execute server-side code
  • To handle database connections
  • To perform client-side validation
  • To store user preferences
The primary purpose of cookies in web applications is to store user preferences, enabling a personalized and persistent experience for users.