Page: 3
Unit-1: The Servlet Technology Model
Q8. Given:
10. public void service(ServletRequest request,
11. ServletResponse response) {
12. ServletInputStream sis =
13. // insert code here
14. }
Which retrieves the binary input stream on line 13?
A. request.getWriter();
B. request.getReader();
C. request.getInputStream();
D. request.getResourceAsStream();
E. request.getResourceAsStream(ServletRequest.REQUEST);
Q9. Click the Exhibit button.
As a maintenance feature, you have created this servlet to allow you to upload and remove files on your web server. Unfortunately, while testing this servlet, you try to upload a file using an HTTP request and on this servlet, the web container returns a 404 status.
What is wrong with this servlet?

A. HTTP does NOT support file upload operations.
B. The servlet constructor must NOT have any parameters.
C. The servlet needs a service method to dispatch the requests to the helper methods.
D. The doPut and doDelete methods do NOT map to the proper HTTP methods.
Q10. Click the Task button.
Place the events in the order they occur.

1st:web container loads the servlet class. 2nd:web container instantiates the servlet 3rd. web container calls the servlets init() method. 4th: web container calls the servlets service() method.’5th: web container calls the servlets destroy() methos.Q11. For an HttpServletResponse response, which two create a custom header?(Choose two.)
A. response.setHeader("X-MyHeader", "34");
B. response.addHeader("X-MyHeader", "34");
C. response.setHeader(new HttpHeader("X-MyHeader", "34"));
D. response.addHeader(new HttpHeader("X-MyHeader", "34"));
E. response.addHeader(new ServletHeader("X-MyHeader", "34"));
F. response.setHeader(new ServletHeader("X-MyHeader", "34"));
Get Answers For All Questions
Page: 3
1
2
3
4
5
6
7
8
9