使用Integer.parseInt來產生一個error,使網頁導到error.jsp
1.使用Integer.parseInt來產生一個error,
使網頁導到error.jsp
=== parseError.jsp ===
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page errorPage="error.jsp" %>
<%
String num = request.getParameter("num");
int cnum = 0;
if(num!=null){
cnum = Integer.parseInt(num);
}
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Parse Error</title>
<form name="pe" action="parseError.jsp">
Convert Number:<input type="text" name="num" value="" /><input type="submit" value="send" name="send" />
</form>
Show th Input :<%=cnum%>
2.error.jsp
<%@page contentType="text/html" pageEncoding="UTF-8" isErrorPage="true"%>
<HTML>
<title>error page</title>
<BODY>
<H1>Error page</H1>
<BR>An error occured in the bean. Error Message is: <%= exception.getMessage()%><BR>
</BODY>
</HTML>