



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




JSP Processong form using a bean
JSP Processing form using a bean
First name:
Last name:
package beans; public class NameBean { private String firstName; // property private String lastName; // property public String getFirstName() { return firstName; } public String getLastName() { return lastName; }
public void setFirstName(String first) { firstName = first; } public void setLastName(String last) { lastName = last; } }
JSP Form results using a bean
JSP Form results using a bean Hello
package beans; public class TemperatureBean { private String temperature;
public String getTemperature() { return temperature ; }
public void setTemperature(String t) { temperature = t; } }
package beans; import java.text.DecimalFormat; public class TemperatureCalculatorBean { private double celsius;
public String getTemperature() { return new DecimalFormat("0.00").format(celsius); }
// continued on next slide
TemperatureCalculatorBean (Contd.):
public void setTemperature(String fahr) { double f; try { f = Double.parseDouble(fahr); } catch (NumberFormatException e) { f = 0.0; } celsius = (f - 32.0) * (5.0 / 9.0); } }
A JSP can forward the request to another
page using
The important idea here is that this new
page receives all the request parameters
of the forwarding page.
Fahrenheit to Celsius Conversion Fahrenheit to Celsius Conversion
Fahrenheit is Celsius.
Convert another ..
Reference
COS 2206 JSP, Barry G. Adams, Department of Mathematics and Computer Science, Laurentain University.