The use of ErrorPage and iserrorpage in JSP __jsp

Source: Internet
Author: User
Tags integer division

compute.html

--------------------------------------------------------------------------------------------------------------- --

<title>Compute</title>
<body bgcolor= "#FFFFFF" >
<div align= "center" >
<form method= "POST" action= "divide.jsp" >
<p>---integer Division---
<p> Dividend
<input type= "text" name= "value1" >
Divisor
<input type= "text" name= "value2" >
</p>
<p>
<input type= "Submit" name= "submit" value= "calculation" >
</p>
</form>
</div>
</body>

--------------------------------------------------------------------------------------------------------------- --

divide.jsp

--------------------------------------------------------------------------------------------------------------- --

<%@ page language= "java" errorpage= "error.jsp"
Contenttype= "TEXT/HTML;CHARSET=GBK"%>
<title>Divide</title>
<body bgcolor= "#FFFFFF" >
<center>
<br>
<%
int dividend = 0;
int divisor = 0;
int result = 0;
try {
Dividend = Integer.parseint (Request.getparameter ("value1"));
catch (NumberFormatException nfex) {
throw new NumberFormatException ("Dividend is not an integer!");
}
try {
divisor = Integer.parseint (Request.getparameter ("value2"));
catch (NumberFormatException nfex) {
throw new NumberFormatException ("Divisor is not an integer!");
}
result = Dividend/divisor;
OUT.PRINTLN (Dividend + "/" + divisor + "=" + result);
%>
<br>
<br>
<br>
<a href= "Javascript:history.back ();" > Return </a>
</center>
</body>

--------------------------------------------------------------------------------------------------------------- --

error.jsp

--------------------------------------------------------------------------------------------------------------- --

<%@ page language= "java" iserrorpage= "true" contenttype= "TEXT/HTML;CHARSET=GBK"%>
<title>compute error</title>
<body bgcolor= "#FFFFFF" >
<div align= "center" >
<br><br>
<p>
<br><br><br>
<a href= "Javascript:history.back ();" > Return </a>
</p>
</div>
</body>

--------------------------------------------------------------------------------------------------------------- --

The final run results show:

When the input numbers can get the correct results

when you enter a different character, it appears as follows:

--------------------------------------------------------------------------------------------------------------- --

Unable to display Web page
The page you are trying to access has a problem and cannot be displayed.

Try the following: Open the localhost:8080 home page and find a link to the information you are interested in. Click the refresh button, or try again later.
Click
Search to find information on the Internet. You can also view a list of related sites.


HTTP 500-Internal server error
Internet Explorer

--------------------------------------------------------------------------------------------------------------- --

Solution Method:

This is the problem of IE itself, in
Internet Options-Advanced--"Browse"--"show friendly HTTP" information (nineth)

--------------------------------------------------------------------------------------------------------------- --

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.