In software engineering, the term refers to an incorrect action or calculation performed by software. In general we can say that the error results from a combination of a defect and a fault. If, as a result of the error, the system performs an undesired actions or fails to perform a desired action, then this is referred as a failure.
An error may be detected by the software which can be handled by raising an exception. eg. 404 or Not found error message is an Http standard response code indicating that the server either could not find what was requested. These errors messages are generated by the browsers. In HTTP error 500, the web server encountered an unexpected condition that prevented it from fulfilling the request by the client. There are many more Http errors codes available. They are not discussed in this example.
The code of the program is given below:
<HTML> <HEAD><TITLE>Generate Error in jsp</TITLE></HEAD> <BODY> This page generates an error when you click the button.<P> <FORM METHOD="POST" ACTION="ErrorPagr.jsp"> <INPUT TYPE="HIDDEN" NAME="errorValue" VALUE="error"> <INPUT TYPE="SUBMIT" VALUE="Generate exception!"> </FORM> </BODY> </HTML>
<% String hiddenvalue = request.getParameter("errorValue"); if ( hiddenvalue.equals("error")) throw new java.lang.NullPointerException(); %>
Output of the Program:
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: February 11, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles