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 package contains servlet classes?
Servlets can be created using the javax.servlet and javax.servlet.http packages, which are a standard part of the Java's enterprise edition, an expanded version of the Java class library that supports large-scale development projects.
Q 2 - Which of the following is true about HTTP Post method?
The POST method sends the encoded user information as a seperate message to page request. It is used to submit form data normally.
Q 3 - Which of the following code retrieves the body of the request as binary data?
request.getInputStream() retrieves the body of the request as binary data using a ServletInputStream.
Q 4 - Which of the following code retrieves the query string that is contained in the request URL after the path?
request.getQueryString() returns the query string that is contained in the request URL after the path.
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 add a date header?
response.addDateHeader(name,date) adds a response header with the given name and date-value.
Q 7 - Which of the following code can be used to set the status code of the response?
response.setLocale(locale) sets the status code of the response.
Q 8 - Which of the following is true about javax.servlet.error.status_code?
javax.servlet.error.status_code attribute gives status code which can be stored and analysed after storing in a java.lang.Integer data type.
Q 9 - Which of the following code is used to get session id of a HTTP Session object in servlets?
session.getId() returns a string containing the unique identifier assigned to this session.
Q 10 - Which of the following code is used to set auto refresh of a page after 5 seconds?
response.setIntHeader("Refresh", 5) sets refresh, autoload time as 5 seconds.