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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access