Using a User Defined Method to Convert Temperatures
I think it's important to work more with developing user defined methods
in JSP pages. They aren't all that difficult to do. But they
can be convenient for all the same reasons developing your own methods are
when developing applications and applets. For example,
Personally, I think developing user interfaces is usually easier in HTML than in Java. So I find I have tendencies towards developing things in JSP rather than more basic Java.
So, the next series of web pages will survey a variety of methods. We will also work with some error handling and importing pre-built packages so that you get more experience with these sorts of things. Almost all of the code should seem very familiar.
You should call this JSP page sticky_temperature.jsp.
<title>A Sticky Form for Converting Temperatures</title>
<body bgcolor = "003344" text="cccccc">
String str_degrees_fahrenheit = request.getParameter("txt_degrees_fahrenheit");
if (str_degrees_fahrenheit == null) str_degrees_fahrenheit = "";
String str_degrees_celsius = request.getParameter("txt_degrees_celsius");
if (str_degrees_celsius == null) str_degrees_celsius = "";
// checking to see if this form has been submitted
|After copying this code and uploading it and accessing it on your web you should see something like the following after entering the initial input and submitting the form for computation.|
|Notice how the decimal places run wild. We will improve on this with a second method based on importing the text.DecimalFormat classes in the next web page.|