Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CSY3020 Internet Programming
JSP Laboratory
1. Complete the exercises from last week which stores and retrieves strings of text to a
data file.
2. Create a HTML file which has a form with two input field for two numbers.  Call a
JSP script which adds the two numbers together and displays the result.  Because JSP
is based on Java, which is a typed language, it is necessary to turn the string received
from the HTML textfield into a float.  This is done by, for example:
HTML


JSP
String n1 = request.getParameter ("n1");
String n2 = request.getParameter ("n2");
double f1 = Float.parseFloat (n1);
double f2 = Float.parseFloat (n2);
3. Integrate the HTML file and the JSP script in 2) into one JSP script.  Note that you
need to give default values to the data you are expecting from the form as they will be
missing the first time the script is called.  For example:
f1 = f2 = 0.0;
if (n1 != null) f1 = Float.parseFloat (n1);
if (n2 != null) f2 = Float.parseFloat (n2);
if (op == null) op = "Add";
4. Add a pull-down menu to allow the user to select which arithmetic function is to be
applied from add, subtract, multiply and divide.
HTML

JSP
String op = request.getParameter ("operation");
:
if (op.equals (“Add”)) f3 = f1 + f2;
5. Create a JSP script which lets you convert from Fahrenheit to Celsius and from
Celsius to Fahrenheit. Formulae: C = (F - 32.0) * (5.0 / 9.0) and F = C *
(9.0/5.0) + 32