Due to the print book page limit, we cannot inlcude all good CheckPoint questions in the physical book. The CheckPoint on this Website may contain extra questions not printed in the book. The questions in some sections may have been reordered as a result. Nevertheless, it is easy to find the CheckPoint questions in the book on this Website. Please send suggestions and errata to Dr. Liang at y.daniel.liang@gmail.com. Indicate the book, edition, and question number in your email. Thanks!

Chapter 37 Check Point Questions

Section 37.2
37.2.1
What is the common gateway interface?
37.2.2
What are the differences between the GET and POST methods in an HTML form?
37.2.3
Can you submit a GET request directly from a URL? Can you submit a POST request directly from a URL?
37.2.4
What is wrong in the following URL for submitting a GET request to the servlet FindScore on host liang at port 8084 with parameter name?
http://liang:8084/findScore?name="P Yates"
37.2.5
What are the differences between CGI and servlets?
Section 37.3
37.3.1
Can you display an HTML file (e.g. c:\test.html) by typing the complete file name in the Address field of Internet Explorer? Can you run a servlet by simply typing the servlet class file name?
37.3.2
How do you create a Web project in NetBeans?
37.3.3
How do you create a servlet in NetBeans?
37.3.4
How do you run a servlet in NetBeans?
37.3.5
When you run a servlet from NetBeans, what is the port number by default? What happens if the port number is already in use?
37.3.6
What is the .war file? How do you obtain a .war file for a Web project in NetBeans?
Section 37.4
37.4.1
Describe the life cycle of a servlet.
37.4.2
Suppose that you started the Web server, ran the following servlet twice by issuing an appropriate URL from the Web browser, and finally stopped Tomcat. What was displayed on the console when the servlet was first invoked? What was displayed on the console when the servlet was invoked for the second time? What was displayed on the console when Tomcat was shut down?
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class Test extends HttpServlet {
  public Test() {
    System.out.println("Constructor called");
  }

  /** Initialize variables */
  public void init() throws ServletException {
    System.out.println("init called");
  }

  /** Process the HTTP Get request */
  public void doGet(HttpServletRequest request, 
      HttpServletResponse response) 
      throws ServletException, IOException {
    System.out.println("doGet called");
  }

  /** Clean up resources */
  public void destroy() {
    System.out.println("destroy called");
  }
}
Section 37.7
37.7.1
What would be displayed if you changed the content type to "html/plain" in Listing 37.2, CurrentTime.java?
37.7.2
The statement out.close() is used to close the output stream to response. Why isn't this statement enclosed in a try-catch block?
37.7.3
What happens when you invoke request.getParameter(paramName) if paramName does not exist?
37.7.4
How do you write a text field, combo box, check box, and text area in an HTML form?
37.7.5
How do you retrieve the parameter value for a text field, combo box, list, check box, radio button, and text area from an HTML form?
37.7.6
If the servlet uses a database driver other than the JDBC-ODBC driver, where should the driver be placed in NetBeans?
Section 37.8
37.8.1
What is session tracking? What are three techniques for session tracking?
37.8.2
How do you create a cookie, send a cookie to a browser, get cookies from a browser, get the name of a cookie, set a new value in the cookie, and set cookie expiration time?
37.8.3
Do you have to create five Cookie objects in the servlet in order to send five cookies to the browser?
37.8.4
How do you get a session, set object value for the session, and get object value from the session?
37.8.5
Suppose you inserted the following code in line 53 in Listing 37.11.
httpSession.setMaxInactiveInterval(1);
What would happen after the user clicked the Confirm button from the browser?
Test your answer by running the program.
37.8.6
Suppose you inserted the following code in line 53 in Listing 37.11.
httpSession.setMaxInactiveInterval(-1);
What would happen after the user clicked the Confirm button from the browser?