Java Spring Multiple Choice Questions & Answers (MCQs) on “Spring Portlet MVC”.
1. DispatcherServtlet dispatches portlet requests to appropriate handlers that handle the requests.
a) True
b) False
Answer: b
Clarification: DispatcherPortlet. It dispatches portlet requests to appropriate handlers that handle the requests. It acts as the front controller of Spring Portlet MVC, and every portlet request must go through it so that it can manage the entire request-handling process.
2. Maps each request to a handler through one or more handler mapping beans.
a) DispatcherServlet
b) DispatcherPortlet
c) All of the mentioned
d) None of the mentioned
Answer: b
Clarification: Once it has picked an appropriate handler, it will invoke this handler to handle the request.
3. In portlets, there are URLs:-
a) render
b) action
c) all of the mentioned
d) none of the mentioned
Answer: c
Clarification: In portlets, there are two types of URLs: render URLs and action URLs.
4. When a user triggers a render URL, the portlet container will ask all the portlets in the same page to handle a render request to render its view.
a) True
b) False
Answer: a
Clarification: When a user triggers a render URL, the portlet container will ask all the portlets in the same page to handle a render request to render its view, unless the view’s content has been cached.
5. When a user triggers an action URL in a portlet, the portlet container will first ask the target portlet to handle an action request.
a) True
b) False
Answer: a
Clarification: A controller should return an object in response to a render request. However, when a user triggers an action URL in a portlet, the portlet container will first ask the target portlet to handle an action request. A controller needn’t return anything for an action request.
6. After Controller has finished handling a render request, it returns:-
a) model name
b) view name
c) view obect
d) all of the mentioned
Answer: d
Clarification: After a controller has finished handling a render request, it returns a model and a view name, or sometimes a view object, to DispatcherPortlet.
7. DispatcherPortlet resolves a view name from one or more view resolver beans.
a) True
b) False
Answer: a
Clarification: DispatcherPortlet renders the view and passes in the model returned by the controller. Note that an action request doesn’t need to render a view.
8. portlet deployment descriptor file is:-
a) portlet.xml
b) portlet.config
c) portlet.xhtml
d) none of the mentioned
Answer: a
Clarification: The Java Portlet specification defines the valid structure of a portlet application, which is very similar to that of a web application, but with the addition of a portlet deployment descriptor (i.e., portlet.xml).
9. Servlet Listener to load the root application context at startup.
a) ContextLoader
b) ContextLoaderListener
c) All of the mentioned
d) None of the mentioned
Answer: b
Clarification: In the web deployment descriptor (i.e., web.xml), you have to register the servlet listener ContextLoaderListener to load the root application context at startup.
10. Unlike in a web application, you can’t control URLs directly in a portlet.
a) True
b) False
Answer: a
Clarification: In the web deployment descriptor (i.e., web.xml), you have to register the servlet listener ContextLoaderListener to load the root application context at startup.
11. You can chain multiple handler mapping annotations as required to portlet.
a) True
b) False
Answer: a
Clarification: Spring Portlet MVC comes with several strategies for you to map portlet requests.
12. The preceding controller handles portlet requests:-
a) render requests
b) action requests
c) all of the mentioned
d) none of the mentioned
Answer: c
Clarification: The preceding controller handles two types of portlet requests: render requests and action requests.
13. When handling a render request, it gets the time zone attribute from the portlet preference.
a) True
b) False
Answer: a
Clarification: When handling a render request, it gets the time zone attribute from the portlet preferences and passes it to the view for editing.
14. When handling an action request, it gets the time zone parameter from the portlet request.
a) True
b) False
Answer: a
Clarification: When handling an action request, it gets the time zone parameter from the portlet request and stores it in the portlet preferences as an attribute, which will override the existing one.
15. The submission URL of this form should be a portlet action URL that will trigger an action request to the current portlet.
a) True
b) False
Answer: a
Clarification: In portlets, you have to construct an action URL with the portlet:actionURL tag defined in the portlet tag library.