[ Team LiB ] 10.2 Automatic Type Conversion
[ Team LiB ] 10.2 Automatic Type Conversion Bean properties can be any type; yet for the most part, JSPs deal with strings. This is certainly true of form parameters, which are the entities that are most often passed to beans’ set methods. If a bean’s set method is expecting an integer and is passed a String, a runtime exception will occur. In most common cases, this potential problem is transparently resolved by the jsp:setProperty and c:set tags, which will try to convert the string to an appropriate type. If the method is expecting an integer, the JSP system will call Integer.parseInt() to obtain an integer value. If this conversion fails, perhaps because the user has entered a string that cannot be turned into an integer, the set method will simply not be called. This can be a problem if some later code expects that all the parameters have been set successfully. There are a few ways to handle this. The first and most obvious is for all set methods to accept strings and do the conversion themselves. However, a more elegant approach would be to use a controller to mediate between the form and the bean. This will be done in Chapter 12. [ Team LiB ] Page 186
Note: If you are looking for reliable and quality webspace company to host and run your servlet application check professional servlet hosting services