Following quiz provides Multiple Choice Questions (MCQs) related to Servlets Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - Which of the following is true about service() method of servlet?
The servlet container (i.e. web server) calls the service() method to handle requests coming from the client( browsers) and to write the formatted response back to the client. Each time the server receives a request for a servlet, the server spawns a new thread and calls service. The service() method checks the HTTP request type (GET, POST, PUT, DELETE, etc.) and calls doGet, doPost, doPut, doDelete, etc. methods as appropriate.
Q 2 - Which of the following method can be used to get the multiple values of a parameter like checkbox data?
You call request.getParameterValues() method if the parameter appears more than once and returns multiple values, for example checkbox.
Q 3 - Which of the following code is used to get cookies in servlet?
request.getCookies() returns an array containing all of the Cookie objects the client sent with this request.
Q 4 - Which of the following code retrieves any extra path information associated with the URL the client sent?
request.getPathInfo() returns any extra path information associated with the URL the client sent when it made this request.
Q 5 - Which of the following code indicates whether the response has been committed?
response.isCommitted() returns a boolean indicating if the response has been committed.
Q 6 - Which of the following code can be used to write a cookie?
response.addCookie(cookie) adds the specified cookie to the response and can be used to write a cookie.
Q 7 - Which of the following are valid servlet filters?
All of the above filters are suggested by the servlet specifications.
Q 8 - When destroy() method of filter gets called?
The destroy() method is called only once at the end of the life cycle of a filter.
Q 9 - Which of the following code is used to delete a HTTP Session object in servlets?
session.invalidate() invalidates this session and unbinds any objects bound to it.
Q 10 - Which of the following code is used to get three-letter abbreviation for this locale's country in servlets?
request.getISO3Country() returns a three-letter abbreviation for this locale's country.