O'Reilly logo

Special Edition Using Java™ 2 Enterprise Edition by Mark Wutka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the request Object

As you saw in Listing 15.2, the getParameter method in the request object retrieves the values of form variable. The lone argument to getParameter is the name of the form variable as it was defined in the HTML form, and must match the case exactly. In other words, if you called a form variable firstName in the HTML file, you must pass "firstName" to getParameter and not "firstname" or "FIRSTNAME."

If you ask the request object for the value of a form variable that does not exist, it returns null. Note that getParameter always returns a string. If you are expecting a number, you have to convert it yourself.

Note

There's a difference between a form variable that is empty and a form variable that does not exist. The value ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required