The Exception Object in JSP

By: Sathya Narayana Emailed: 1646 times Printed: 2119 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

The exception object is an instance of the java.lang.Throwable class. It's available in error pages only, and it represents the exception that occurred that caused control to pass to the error page. Its most useful methods are as follows.

getLocalizedMessage() returns a localized description of this Throwable object. In many cases, this will return the same result as getMessage():

public String getLocalizedMessage()

getMessage() returns the error message string of this Throwable object:

public String getMessage()

printStackTrace() prints information about this Throwable object, along with a listing of the method calls that led to the error condition arising. The output can be directed to the standard error stream or to a specified PrintStream or PrintWriter object:

public void printStackTrace()
public void printStackTrace(PrintStream ps)
public void printStackTrace(PrintWriter pw)

toString() returns a short description of this Throwable object:

public String toString()

If an error message was supplied when the object was created, the result is the Throwable class's name, followed by a colon and a space, followed by that message. For example, the following:

<%
try
{
throw new Exception("Here's my Exception");
}
catch(Exception e)
{
out.print(e.toString());
}
%>

outputs the following: java.lang.Exception: Here's my Exception.


JSP Home | All JSP Tutorials | Latest JSP Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Sathya Narayana
Querying Data with the JSTL in JSP
Deleting Data in MySQL
Modifying data and using WHERE clause in MySQL
Querying the Database in MySQL
Inserting Data into Tables in MySQL
Changing the Structure of an Existing Table in MySQL
The Exception Object in JSP
The Application Object in JSP
The Session Object in JSP
The Out Object in JSP
The Response Object in JSP
The Request Object in JSP
Tag Libraries in JSP
Scriptlets and Expressions in JSP
Declarations in JSP

More Tutorials in JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
JSP Alert Example
JSP CheckBox Example
Uploading an Image to a Database using JSP
Uploading a file to a server using JSP
A JSP page that gets properties from a bean
The page Directive in JSP
The taglib, tag, include, attribute and the variable Directive in JSP
Declarations in JSP
Scriptlets and Expressions in JSP
Tag Libraries in JSP
The Request Object in JSP
The Response Object in JSP
The Out Object in JSP
The Session Object in JSP

More Latest News
Most Viewed Articles (in JSP )
JSP CheckBox Example
JSP Program for display Date
JSP Example to connect to MS SQL database and retrieve records
Sending Email using JSP
What are the different scopes in JSP?
JSP Alert Example
Comparison operators in JSP
Uploading a file to a server using JSP
Uploading an Image to a Database using JSP
Automatically Refreshing a JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
The JSP Program running first Time.
Embedding java codes in jsp sciptlets
Protecting your website with a login page
Form Object
Most Emailed Articles (in JSP)
Steps to get a Free SSL certificate for your Tomcat
What is JSP?
Retrieving a Portion of a String
Tags using in jsp
Tag libraries
Closing Windows
Radio Object
Frame Object
Math Object
Disabling Scriptlets in JSP using web.xml
Getting HTTP Request Headers in a JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
What is JSP?
Click to Activate and Use this control
Built-in Object in Javascript