我对 servlet 有点陌生,我正在使用NetBeans,我有一个 servlet,它接受来自用户的数字并打印它的乘法表。
我有TableServlet.java
如下-->
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class TableServlet extends HttpServlet
{
@Override
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{
PrintWriter out=response.getWriter();
response.setContentType("text/html");
String s=request.getParameter("t1");
int x= Integer.parseInt(s);
for(int i=1;i<=10;i++)
{
out.println(x+"x"+i+"="+i*x);
}
out.close();
}
}
我有newhtml.html
如下-->
<html>
<body>
<form action="TableServlet" method="get">
Enter any number
<input type="text" name="t1" />
<input type="submit" value="GetTable"/>
</form>
</body>
</html>
它已成功部署,但运行此项目后在浏览器上找不到输出。相反,我只能在浏览器上看到这个-->
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NumberFormatException: null
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.
GlassFish Server Open Source Edition 3.1.2.2
可能是什么原因 ?