The _________ method of RequestDispatcher is used for including content of another resource in the response.
- execute()
- forward()
- include()
- sendRedirect()
The include() method of RequestDispatcher is used for including content of another resource in the response.
Servlets can be used to handle ______, while JSP is used for presenting these to the users.
- HTTP requests
- business logic
- database operations
- presentation
Servlets are commonly used for handling business logic, database operations, etc., while JSP is primarily used for presenting content to users.
A servlet needs to handle a file upload from a web form. Which HTTP method and content type should be used?
- DELETE with text/plain
- GET with application/x-www-form-urlencoded
- POST with multipart/form-data
- PUT with application/json
For handling file uploads, the appropriate combination is to use the POST method along with the multipart/form-data content type.
ServletContext allows servlets to __________ resources and information.
- access
- initialize
- restrict
- share
ServletContext allows servlets to share resources and information.
How does the servlet container handle thread safety in the case of servlets?
- By creating a new thread for each request.
- By making the service() method synchronized.
- By using a single thread for all requests.
- Thread safety is the responsibility of the developer.
The servlet container handles thread safety by making the service() method synchronized to ensure that only one thread executes it at a time, preventing race conditions in shared resources.
What is the impact of calling request.getParameter() after request.getInputStream() or request.getReader() in a servlet?
- It will result in a compilation error.
- It will retrieve the parameter value successfully.
- It will return null.
- It will throw a runtime exception.
Calling request.getParameter() after request.getInputStream() or request.getReader() will return null because the input stream or reader can be consumed only once, and they might have already been read.
A servlet needs to load database settings at startup. How should these settings be passed to the servlet?
- Hardcode the settings in the servlet code
- Store settings in a local properties file
- Use ServletContext parameters
- Use request parameters
The recommended approach is to use ServletContext parameters to pass settings at servlet startup, as they can be accessed by all servlets within the same web application. Hardcoding or using request parameters may not be suitable for initialization settings.
Which HTTP method is idempotent: GET or POST?
- DELETE
- GET
- POST
- PUT
The GET method is idempotent, meaning multiple identical requests have the same effect as a single request. This is because GET requests do not change the state on the server.
Which of the following is NOT a common security threat that AEM needs protection against?
- Cross-Site Request Forgery (CSRF)
- Cross-Site Scripting (XSS)
- SQL Injection
- Social Media Marketing
AEM needs protection against common threats like XSS, SQL Injection, and CSRF, but Social Media Marketing is not a direct security threat in this context.
Scenario: A content author needs to update a webpage on an AEM-powered website. How does the content structure facilitate this task?
- Flat Content Structure for Simplicity
- Modular Components for Reusability
- Random Folder Organization
- Role-Based Permissions
A modular content structure with reusable components facilitates easy updates for content authors in AEM, enhancing efficiency.