我想在NetBeans8中运行一个jsp项目。这个项目建设成功,但它没有运行。我有一个a.jsp和main.html。我在下面写下这些代码。我用apache tomcat8运行它们。请帮助我运行它。
main.html:
<html>
<title>Sample Example</title>
<body>
<h1>Example of JSP</h1>
<b>Mathematics</b>
<hr>
<form method = "post" action = "a.jsp">
<font size = "5" face = "Time New Roman">
<input type = "radio" name = "a1" value = "add" checked>Addition<br>
<input type = "radio" name = "a1" value = "mul">Multiplication<br>
<input type = "radio" name = "a1" value = "div">Multiplication<br>
</font>
<br><br>
Enter first value <input name = "t1" value = ""><br>
Enter second value <input name = "t2" value = ""><br>
<input type = "submit" name = "result">
</form>
</body>
</html>
a.jsp:
<%@page language = "java"%>
<%@page import = "java.lang.*"%>
<!DOCTYPE html>
<html>
<body>
<h1><center>Result for<%=request.getParameter("a1")%></center></h1>
<%
int number1 = Integer.parseInt( request.getParameter( "t1" ) );
int number2 = Integer.parseInt( request.getParameter( "t2" ) );
int result = 0;
String operation = request.getParameter( "a1" );
if(operation.equals( "add" ) )
result = number1 + number2;
if( operation.equals( "mul" ) )
result = number1 * number2;
if( operation.equals( "div" ) )
result = number1 / number2;
%>
Result is<%=result%>
</body>
</html>