Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
The errorPage Attribute of page Directive In JSP 
 

This section illustrates you about the errorPage attribute of the page directive in JSP.

 

The errorPage Attribute of page Directive In JSP

                         

This section illustrates you about the errorPage attribute of the page directive in JSP. This attribute sets a url (relative path starting from the "/" which refers from the root directory of your JSP application). If any exception is generated the the attribute refers to the file which is mentioned in the given url. If you do not specify the url then the attribute refers to the current page of your JSP application if any exception generated.

Here, this section provides the two JSP files these are:

  • ErrorPageAttribute.jsp
  • error.jsp

About the ErrorPageAttribute.jsp page:

This page show a simple text box in which you have to enter a number and a button which is used for submission the html form and divided the entered number by 0 (Zero) i.e. the cause of generating an error and the page is redirected to the specified file name which is mentioned as the value of the errorPage attribute of the page directive.

About the error.jsp page:

This page shows the error generated in the calling JSP page because of dividing the entered number by zero or any type of the error when the value of the isErrorPage attribute is set with the true value.

Here is the code of the ErrorPageAttribute.jsp page:

<%@page errorPage="error.jsp" %>
<html>
	<head><title>Showing Error Page.</title></head>
	<body>
		<form method="post">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>Enter a number: </td>
					<td><input type="text" name="txtNum" />
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input type="submit" name="B1" value=
"Divide by zero" />
				</tr>
			</table>
		</form>
		<%
			if(request.getParameter("txtNum") != null){
				if(!request.getParameter("txtNum").equals("")){
					int div = Integer.parseInt(request.
getParameter("txtNum")) / 0;
					out.println("Answer is: " + div);
				}			
				else{
					out.println("<html><font color=red>Please
 enter a number.</font></html>");
				}
			}
		%>
	</body>
</html>

Output for the ErrorpageAttribute.jsp page:

Here is the code of the error.jsp page:

<%@page isErrorPage="true" %>
<html>
	<head><title>Error Page.</title></head>
	<body bgcolor="blue">
		<font size="16" color="white">Your page generated
 an error:"<br/>
		Exception:<br/></font>
		<%= exception.toString() %>
	</body>
</html>

Output for the error.jsp page:

Download ErrorPageAttribute.jsp file.

Download error.jsp file.

                         

» View all related tutorials
Related Tags: c string stl io sed arguments type jstl boolean tag return ole this oo check js if boo ie with

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

2 comments so far (
post your own) View All Comments Latest 10 Comments:

the code is not functioning properly,,
its showing this error when i enter some value
but if i enter no value then its functioning properly

The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.

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

Please try the following:

Open the localhost:8080 home page, and then look for links to the information you want.
Click the Refresh button, or try again later.

it gave following error when i enter a number and hit the "divide by 0"

its working fine when i dont give any value to the field



Click Search to look for information on the Internet.
You can also see a list of related sites.




HTTP 500 - Internal server error
Internet Explorer

Posted by kunal on Thursday, 11.8.07 @ 14:16pm | #36592

This code works fine for tomcat, but its not working on JBoss 4.0.4.GA

Posted by r on Thursday, 04.5.07 @ 19:06pm | #13404

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.