jsp程序报错,找不到原因,请大家帮忙
tomcat7.0
html程序:
<html>
<head>
<title>Compute</title>
<meta http-equiv="Content-type" content="text/html" charset="gb2312">
</head>
<body bgcolor="#FFFFFF">
<div align="center">
<form method="post" action="Compute.jsp">
<p>选择要做的运算
<input type="radio" name="compute" value="division" checked>
除法
<input type="radio" name="compute" value="multiplication">
乘法
</p>
<p>被除数(被乘数)
<input type="text" name="value1">
除数(乘数)
<input type="text" name="value2">
</p>
<p>
<input type="submit" name="Sbumit" value="计算结果">
</p>
</form>
</div>
</body>
</html>
jsp程序:
<%@ page language="java" %>
<%
String value1 = request.getParameter("value1");
String value2 = request.getParameter("value2");
%>
<% if(request.getParameter("compute").equals("division")) { %>
<jsp:include page="divide.jsp" flush="true">
<jsp:param name="v1" value="<%=value1%>"/>
<jsp:param name="v2" value="<%=value2%>"/>
</jsp:include>
<% } else { %>
<jsp:include page="multiply.jsp" flush="true">
<jsp:param name="v1" value="<%=value1%>"/>
<jsp:param name="v2" value="<%=value2%>"/>
</jsp:include>
<% } %>
?
运行以后总报:
org.apache.jasper.JasperException: An exception occurred processing JSP page /include/Compute.jsp at line 8
5: String value2 = request.getParameter("value2");
6: %>
7: <% String value = request.getParameter("compute");%>
8: <% if(value.equals("division")) { %>
9: <jsp:include page="divide.jsp" flush="true">
10: <jsp:param name="v1" value="<%=value1%>"/>
11: <jsp:param name="v2" value="<%=value2%>"/>
[解决办法]
<% if(value.equals("division")) { %>
这里出错了。目测是空指针value为空
[解决办法]
if(request.getParameter("compute").equals("division")) {
-->
if("division".equals(request.getParameter("compute"))) {