error.jsp
<body>
<%@ page isErrorPage="true"%>
<h2>Sorry, your application generating an exception</h2>
Exception is : <%=exception %>
</body>
index.html
<form action="process.jsp">
No1 : <input type="text" name="n1"><br><br>
No2 : <input type="text" name="n2"><br><br>
<input type="submit" value="Divide">
</form>
process.jsp
<%@ page errorPage="/error.jsp" %>
<%
String num1=request.getParameter("n1");
String num2=request.getParameter("n2");
int a = Integer.parseInt(num1);
int b = Integer.parseInt(num2);
int c = a/b
out.println("Division of numbers is : "+c);
%>
当我用零设计任何数字时,内部网络浏览器会给出"Http 500服务器内部错误",当我更改网络浏览器时,它会给我正确的输出
我发现IE有一个默认打开的功能-显示友好的HTTP错误消息(转到工具->互联网选项->高级->取消选中显示友好的HTTP错误消息(。然后在Eclipse IDE中执行。为我工作!