Java Servlets   «Prev  Next»

Servlets Generate HTML - Quiz

Each question is worth one point. Select the best answer or answers for each question.
 
1. The HTTP request object passed to your server represents:
Please select the best answer.
  A. The information your servlet will send back to the browser
  B. The information the browser sent to the server
  C. The user’s email address
  D. An object to which you can write HTML


2. The doGet() method of a servlet:
Please select the best answer.
  A. Sometimes uses the HTTP request object
  B. Always uses the HTTP request object
  C. Changes the values in the HTTP request object
  D. Cannot access the HTTP request object

3. Before writing any HTML to a response object, which tasks must be performed? Please select all the correct answers.
  A. Clear the response
  B. Set the content type of the response to plain text HTML andcreate an output writer object associated with the response
  C. Create a response object
  D. Create a request object associated with the response

4. To write HTML to a writer object associated with an HTTP response, what method do you use?
Please select the best answer.
  A. printHtml()
  B. write()
  C. writeHtml()
  D. println()

5. What is the extension for an HTML file that will have part of its content filled in with a server side include?
Please select the best answer.
  A. .html
  B. .ihtml
  C. .shtml
  D. .inc


6. The <SERVLET> tag is used when including servlet output in a page of ordinary HTML. What is the only required attribute for the <SERVLET> tag?
Please select the best answer.
  A. ALT
  B. CODE
  C. BORDER
  D. CODEBASE

7. To get a session object, you call a method of which class?
Please select the best answer.
  A. HttpServlet
  B. HttpServletRequest
  C. HttpServletResponse
  D. ServletException


8. If two users are requesting pages from the same server at the same time, which of the following statements are true?
Please select the best answer.
  A. The server will create a single session object and the servlets will share it
  B. The server will create two session objects, one for each user
  C. Servlets may create sessions, one for each user
  D. The second user will have to wait until the first session is over


9. The parameter passed to the getSession() method of the request object can have the values true or false. What does a value of true mean?
Please select the best answer.
  A. Your code will be changing session variables
  B. Your code will be using the values of session variables
  C. A new session should be created if none exists
  D. An existing session should be reused


10. Which statement describes the way most programmers work with servlets and forms?
Please select the best answer.
  A. The form is kept in a separate HTML and only doPost() can process it
  B. The form is kept in a separate HTML file, and both doGet() and doPost() can process it
  C. doGet() generates the form HTML, and both doGet() and doPost() can process it
  D. doGet() generates the form HTML, and doPost() processes it

11. The getParameterValues() of the HTTP request object gives you:
Please select the best answer.
  A. A string holding all the form field values
  B. An array of strings, each holding one form field value
  C. An array of strings, each holding a value for the field you specify
  D. An array of Object references, a mixture of strings and numbers

Your score is 0.0