[ Team LiB ] Previous Section Next Section

Workshop

The Workshop is designed to help you review what you have learned and to help you to further increase your understanding of the material covered in this chapter.

Quiz

1:

What are the names of the two objects discussed in this hour that are "built into" JSPs?

2:

The getParameter method is used to obtain the value of a form variable. What object is this method part of?

3:

Explain the difference between the doGet and doPost methods of HttpServlet.


Answers

A1:

Several objects are made available to JSPs. The two implicit objects that are discussed in this chapter are

  • out, which provides a stream to write output content to.

  • request, which is a reference to an instance of HttpRequest. It's used to access many of the attributes of the HTTP request that triggered the service invocation, including the names of any form names and values.

A2:

getParameter is a method of HttpRequest and is available through the request implicit object.

A3:

These methods are used to handle HTTP GET and POST request methods, respectively. The default implementation for either indicates that the method is not supported. You must override the methods in order to be able to work with the request types you are interested in handling.


Activities

  1. Write an HTML form that includes a checkbox and other HTML form elements. Make the form use the GET request method. Write a JSP handler that returns the values for each element.

  2. Change the form above to use the form POST method. Discover whether any changes are required to handle a POST. Look at the generated source code for the JSP.

    [ Team LiB ] Previous Section Next Section