A Sticky Form With Only Textboxes
Introduction.
Now we need to start working with forms that have the potential to do the
following.
The jargon that is often used to describe such forms is sticky forms. Everyone has probably had the experience of going to a web site, filling in a lot of information, pressing a submit button and then being routed back to the same form without having all the work you've just entered be present. I find this very irritating and far too prevalent. Intelligent use of sticky forms is terribly important in web development. Our first example does the following
You should call this JSP page sticky_textboxes.jsp. |
<html> <head> <title>A Sticky Form for Formatting Inputs</title> </head> <body bgcolor = "003344" text="cccccc"> <% // obtaining the inputs from the form into local variables String first_name = request.getParameter("txt_first_name"); if (first_name == null) first_name = ""; String last_name = request.getParameter("txt_last_name"); if (last_name == null) last_name = ""; String email = request.getParameter("txt_email"); if (email == null) email = ""; // checking to see if this form has been submitted if (request.getMethod().equals("POST")) {
} |
After copying this code and uploading it and accessing it on your web you should see something like the following after pressing the submit button on a largely blank form. |
The code has a couple new aspects that need to be
discussed.
|