我的JSP的HelloWorld
在4317机房,跟着小海写下第一个JSP。
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'a.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
double r, s;
String radius = request.getParameter("radius");
if (radius == null)
s = 0;
else {
r = Double.parseDouble(radius);
s = 3.14159*r*r;
}
%>
<font size=6 color=red>圆面积计算</font>
<form action="" method="post" name=f1>
请输入半径
<input type=text name=radius value="0" size=5 />
面积=
<input type=text name=area value="0" size=5 />
<input type="submit" value="计算" />
</form>
</body>
</html>
<script language="javascript">
document.f1.area.value="<%=s%>";
document.f1.radius.value="<%=radius%>";
</script>

浙公网安备 33010602011771号