Page: 10
Unit- 3: The Web Container Model
Q 28. Click the Task button.
Place the XML elements in the web application deployment descriptor solution to configure a servlet context event listener named com.example.MyListener.

Answers:
<listener>
<listener-class>com.example.MyListener< listener-class>
</listener>
Q 29. Which is true about the web container request processing model?
A. The init method on a filter is called the first time a servlet mapped to that filter is invoked.
B. A filter defined for a servlet must always forward control to the next resource in the filter chain.
C. Filters associated with a named servlet are applied in the order they appear in the web application deployment descriptor file.
D. If the init method on a filter throws an UnavailableException, then the container will make no further attempt to execute it.
Answer: C
Q30. Your IT department is building a lightweight Front Controller servlet that invokes an application logic object with the interface:
public interface ApplicationController {
public String invoke(HttpServletRequest request)
}
The return value of this method indicates a symbolic name of the next view. From this name, the Front Controller servlet looks up the JSP URL in a configuration table. This URL might be an absolute path or a path relative to the current request. Next, the Front Controller servlet must send the request to this JSP to generate the view. Assume that the servlet variable request is assigned the current HttpServletRequest object and the variable context is assigned the webapp's ServletContext.
Which code snippet of the Front Controller servlet accomplishes this goal?
A. Dispatcher view
= context.getDispatcher(viewURL);
view.forwardRequest(request, response);
B. Dispatcher view
= request.getDispatcher(viewURL);
view.forwardRequest(request, response);
C. RequestDispatcher view
= context.getRequestDispatcher(viewURL);
view.forward(request, response);
D. RequestDispatcher view = request.getRequestDispatcher(viewURL);
view.forward(request, response);
Answer: D
Page: 10
1
2
3
4
5
6
7
8
9
10