What is the result of a client request of the Source servlet with no query string?

Click the Exhibit button. Given the web application deployment descriptor elements:
11. <filter>
12. <filter-name>ParamAdder</filter-name>
13. <filter-class>com.example.ParamAdder</filter-class>
14. </filter>

31.<filter-mapping>
32.<filter-name>ParamAdder</filter-name>
33.<servlet-name>Destination</servlet-name>
34.</filter-mapping>

55.<servlet-mapping>
56.<servlet-name>Destination</servlet-name>
57.<url-pattern>/dest/Destination</url-pattern>
58.</servlet-mapping>
What is the result of a client request of the Source servlet with no query string?
//Source Servlet:Source.java
public class Source extends HttpServlet{
public void service(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
RequestDispatcher rd=request.getRequestDispatcher("/dest/Destination");
rd.forward(request,response);
}
}
//Filter:ParamAdder.java
public class ParamAdder implements Filter{
//…
public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain)
throws ServletException,IOException{
request.setAttribute("filterAdded","addedByFilter");
chain.doFilter(request,response);
}
//…
}
//Destination Servlet Destination.java
public class Destination extends HttpServlet{
public void service(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
String filterParam=(String)request.getAttribute("filterAdded");
response.getWriter().println("filterAdded="+filterParam);
}
}
A. The output "filterAdded = null" is written to the response stream.
B. The output "filterAdded = addedByFilter" is written to the response stream.
C. An exception is thrown at runtime within the service method of the Source servlet.
D. An exception is thrown at runtime within the service method of the Destination servlet.

Download Printable PDF. VALID exam to help you PASS.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.