Servlet AJP Assignment Unit 6
Servlet AJP Assignment Unit 6
10. Which method can be used to send a response to the client in a servlet?
a) getRequest() b) sendResponse() c) getResponse() d) HttpServletResponse.getWriter()
11. How can you obtain the value of a request parameter in a servlet?
a) Using the `request.getAttribute()` method b) Using the `request.getParameter()` method
c) Using the `request.getSession()` method d) Using the `request.getAttribute()` method
14. Which HTTP status code indicates that a resource is not found?
a) 200 OK b) 302 Found c) 404 Not Found d) 500 Internal Server Error
15. Which interface must a servlet implement to handle session events?
a) HttpSessionListener b) HttpSessionAttributeListener
c) ServletContextListener d) ServletRequestListener
20. Which of the following is NOT a valid way to create a servlet in Java?
a) Extending the `HttpServlet` class b) Implementing the `Servlet` interface
c) Using the `new` keyword d) Extending the `GenericServlet` class
25. Which of the following is NOT a valid method of communication between servlets?
a) Using the `ServletContext` b) Using the `HttpServletResponse`
c) Using the `RequestDispatcher` d) Using HTTP sessions
27. Which HTTP method is used to retrieve data from the server in a safe and idempotent way?
a) GET b) POST c) PUT d) DELETE
35. Which of the following is NOT a valid content type for an HTTP response?
a) text/html b) application/json c) image/png d) audio/mp3
41. Which of the following is NOT a valid HTTP status code for a successful response?
a) 200 OK b) 201 Created c) 204 No Content d) 404 Not Found
44. Which of the following is NOT a valid method of managing session tracking in servlets?
a) Using cookies b) Using URL rewriting c) Using session IDs d) Using request attributes
45. Which of the following is NOT a valid content type for an HTTP response?
a) text/html b) application/json c) image/jpeg d) audio/wav
51. Which of the following is NOT a valid HTTP response header in a servlet?
a) Content-Type b) Location c) Session-ID d) Set-Cookie
53. How can you include the content of another resource in a servlet response?
a) By using the `RequestDispatcher.include()` method b) By using the `HttpServletResponse.include()` method
c) By using the `RequestDispatcher.forward()` method d) By using the `HttpServletResponse.forward()` method
54. How can you obtain the value of a servlet's initialization parameter in a servlet?
a) Using the `initParameter()` method of the `ServletConfig` object
b) Using the `getParameter()` method of the `HttpServletRequest` object
c) Using the `getAttribute()` method of the `ServletContext` object
d) Using the `getParameter()` method of the `HttpServletResponse` object
55. How is the dynamic interception of requests and responses to transform the information done.
a) sevlet container b)servlet config c)servlet context d)sevlet filter
56. Which type of servletengine is a server that includes built-in support for servlets.
a) Add-onServletEngine b)EmbeddedServletEngine c)StandaloneServletEngine d)None of the above
58. Which Cookie it is valid for single session only and it is removed each time when the user closes the
browser. a)President Cookie
b) Non-president cookie
c)all of the above
d) None of the above
59. Session is the part of the SessionTracking and it is for maintaining the client state at server side.
a) true b)false c)none d)All
61. Web server is used for loading the init() method of servlet.
a) true b)false c)None d)All
63. Which method is used send the same request and response objects to another servlet in RequestDispatcher().
a) forward b)sendRedirect() c)Both a and a d)None of the above