When a web application is redeployed with updated servlet configuration in web.xml, how does it affect the running servlets?
- The redeployment process has no impact on running servlets.
- The running servlets are automatically updated with the new configuration.
- The running servlets need to be restarted to apply the new configuration.
- The updated configuration only applies to newly created servlet instances.
When a web application is redeployed with updated servlet configuration, the running servlets are not automatically updated. To apply the new configuration, the running servlets need to be restarted.
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.
Which one directly interacts with the Java server pages (JSP) container?
- CSS
- HTML
- JSP
- Servlets
Servlets directly interact with the JavaServer Pages (JSP) container.
A ________ is a unique identifier generated by the server and sent to the client to maintain a session.
- Cookie
- Session ID
- Token
- URL Rewriting
The term for a unique identifier generated by the server and sent to the client to maintain a session is a Cookie.
What is a significant difference in how session data is handled between RequestDispatcher's forward and HttpServletResponse's sendRedirect?
- Session data is duplicated
- Session data is lost
- Session data is modified
- Session data is shared
When using HttpServletResponse's sendRedirect, the session data is typically lost because it involves a new request. In contrast, RequestDispatcher's forward method allows the sharing of session data, maintaining it throughout the forwarding process, providing a more seamless user experience with consistent session information.
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.