当前位置: 代码迷 >> Java Web开发 >> [求助]求三角形面积报错
  详细解决方案

[求助]求三角形面积报错

热度:275   发布时间:2007-07-22 07:08:01.0
[求助]求三角形面积报错

报错为
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:532)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.NullPointerException
sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
java.lang.Double.parseDouble(Unknown Source)
org.apache.jsp.triangle_jsp._jspService(triangle_jsp.java:96)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.

源代码为

<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import ="java.math.*" %>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="javax.servlet.*"%>
<HTML>
<BODY>
<body bgcolor=fadded text=6f7a83 >
<P> <center><font size=5><b>在下面的表格输入三角形三边:</font></center>
<FORM action="triangle.jsp" method=post name=form>
<Table align="CENTER" >
<font size=3>
<TR>
<TH width=60> 第一边</TH>
<TH width=60> 第二边</TH>
<TH width=60> 第三边</TH>
</TR></font>
<%
out.print("<TR>");
out.print("<TD>");
out.print("<INPUT type=text name=first value=0>");
out.print("</TD>");
out.print("<TD>");
out.print("<INPUT type=text name=second value=0>");
out.print("</TD>");
out.print("<TD>");
out.print("<INPUT type=text name=third value=0>");
out.print("</TD>");
out.print("</TR>");

%>
</Table>
<INPUT type=submit name="g" value="提交" >
</FORM>
<%
String fi=request.getParameter("first");
String se=request.getParameter("second");
String th=request.getParameter("third");
Double a=Double.parseDouble(fi);
Double b=Double.parseDouble(se);
Double c=Double.parseDouble(th);
Double p;
p=(a+b+c)/2;
double s,len;
len=a+b+c;
s=Math.sqrt(p*(p-a)*(p-b)*(p-c));
%>
<Font size=4 color=Purple>
<center>
<b>
<P><BR>查看周长:
<%=len%><br>
<P><BR>查看面积:
<%=s%>
</b>
</center>
</Font>
</BODY>
</HTML>
搜索更多相关主题的帖子: 三角形  面积  

----------------解决方案--------------------------------------------------------
  相关解决方案