Java & J2EE Page 5 - Developing JavaServer Pages |
In the last figure, you learned how to use the getParameter method to return the value that the user entered into a textbox. Now, Figure 5 summarizes that method and illustrates it in a new context. This figure also summarizes and illustrates two more methods of the implicit request object. Figure 5: How to use the methods of the request object Three methods of the request object
More Scriptlets A scriptlet that determines if a checkbox is checked
A scriptlet that reads and displays multiple values from a list box
A scriptlet that reads and displays all request parameters and values
Description You can use the getParameter method to return the value of the selected radio button in a group or the selected item in a combo box. You can also use it to return the value of a selected check box or independent radio button, but that value is null if it isn't selected. If an independent radio button or a checkbox doesn't have a Value attribute, this method returns "on" if the control is selected or null if it isn't. In most cases, the getParameter method returns the value of the parameter. For a textbox, that's usually the value entered by the user. But for a group of radio buttons or a combo box, that's the value of the button or item selected by the user. For checkboxes or independent radio buttons that have a Value attribute, the getParameter method returns that value if the checkbox or button is selected and a null value if it isn't. For checkboxes or independent radio buttons that don't have a Value attribute, though, the getParameter method returns an "on" value if the checkbox or button is selected and a null value if it isn't. This is illustrated by the first example in this figure.
blog comments powered by Disqus |