Top Description Fields Constructors Methods
jakarta.servlet

public Class ServletException

extends Exception
Class Inheritance
Known Direct Subclasses
jakarta.servlet.UnavailableException

Defines a general exception a servlet can throw when it encounters difficulty.
Author
Various

Field Summary

Modifier and TypeField and Description
private Throwable
private static final long

Constructor Summary

AccessConstructor and Description
public
ServletException()

Constructs a new servlet exception.

public
ServletException(String
a String specifying the text of the exception message
message
)

Constructs a new servlet exception with the specified message.

public
ServletException(String
a String containing the text of the exception message
message
,
Throwable
the Throwable exception that interfered with the servlet's normal operation, making this servlet exception necessary
rootCause
)

Constructs a new servlet exception when the servlet needs to throw an exception and include a message about the "root cause" exception that interfered with its normal operation, including a description message.

public
ServletException(Throwable
the Throwable exception that interfered with the servlet's normal operation, making the servlet exception necessary
rootCause
)

Constructs a new servlet exception when the servlet needs to throw an exception and include a message about the "root cause" exception that interfered with its normal operation.

Method Summary

Modifier and TypeMethod and Description
public Throwable

Returns:

the Throwable that caused this servlet exception
getRootCause
()

Returns the exception that caused this servlet exception.

Field Detail

rootCauseback to summary
private Throwable rootCause
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

Constructor Detail

ServletExceptionback to summary
public ServletException()

Constructs a new servlet exception.

ServletExceptionback to summary
public ServletException(String message)

Constructs a new servlet exception with the specified message. The message can be written to the server log and/or displayed for the user.

Parameters
message:String

a String specifying the text of the exception message

ServletExceptionback to summary
public ServletException(String message, Throwable rootCause)

Constructs a new servlet exception when the servlet needs to throw an exception and include a message about the "root cause" exception that interfered with its normal operation, including a description message.

Parameters
message:String

a String containing the text of the exception message

rootCause:Throwable

the Throwable exception that interfered with the servlet's normal operation, making this servlet exception necessary

ServletExceptionback to summary
public ServletException(Throwable rootCause)

Constructs a new servlet exception when the servlet needs to throw an exception and include a message about the "root cause" exception that interfered with its normal operation. The exception's message is based on the localized message of the underlying exception.

This method calls the getLocalizedMessage method on the Throwable exception to get a localized exception message. When subclassing ServletException, this method can be overridden to create an exception message designed for a specific locale.

Parameters
rootCause:Throwable

the Throwable exception that interfered with the servlet's normal operation, making the servlet exception necessary

Method Detail

getRootCauseback to summary
public Throwable getRootCause()

Returns the exception that caused this servlet exception.

Returns:Throwable

the Throwable that caused this servlet exception