test.java
package com;
public class test{
private String tangle1;
private String tangle2;
private double area;
public void setTangle1(String d){
this.tangle1=d;
}
public String getTangle1(){
return this.tangle1;
}
public void setTangle2(String d){
this.tangle2=d;
}
public String getTangle2(){
return this.tangle2;
}
public double getArea(){
if(tangle1!=null&&tangle2!=null)
return 0.5*Double.parseDouble(tangle1)*Double.parseDouble(tangle2);
else return 0.0;
}
}
test.jsp
<%@ page contentType="text/html;Charset=gbk"%>
<html>
<body>
<center>
<font size="20">
<form action="" method="post">
直角边1<input type="text" name="tangle1"><br>
直角边2<input type="text" name="tangle2"><br>
<input type="submit" value=" 提 交 ">
</form>
三角形的面积是:
<jsp:useBean id="cal" class="com.test" scope="page"/>
<jsp:setProperty name="cal" property="*"/>
<jsp:getProperty name="cal" property="area"/>
</center>
</body>
</html>
posted on 2009-03-30 09:38
鹏凌 阅读(215)
评论(0) 编辑 收藏