JspException in custom tag

K

kingkong

Hello,

Can someone show me the error of my ways.....

I have a custom tag 'public int doStartTag() throws JspException' from
which a JspException is thrown. The exception is forwarded to an JSP
error page and from there I want to (eventually) shove the contents of
the exception into a javabean.

My javabean is set up as follows:

public class errorBean
{
Throwable errorObject = null;
String errorMessage = null;

public void setErrorObject(Throwable errorObject)
{
this.errorObject = errorObject;
errorMessage = errorObject.getMessage();
}
public String getErrorMessage()
{
return errorMessage;
}
} //errorBean


My JSP error page looks like:

<%@ page isErrorPage="true" %>

<html>
<body>

<jsp:useBean id="errorBean" class="errorBean"/>
<jsp:setProperty name="errorBean" property="errorObject"
value="${pageContext.errorData.throwable}"/>
The error message is <jsp:getProperty name="errorBean"
property="errorMessage"/>


</body>
</html>

When I throw an exception like 'throw new JspException("Hello World")'
in my custom tag,
everything seems to work i.e. "Hello World" shows up in my Mozilla &
Netscape browser.
When I throw an exception like 'throw new JsPException("Hello
World",throwableObject)
where throwableObject subclasses Throwable, I get a 'http status 500'
error, but the browser clearly displays as part of a stack trace (?)
the exception "Hello World" as well as the root cause.

Why would this work in one case ('throw new JspException("Hello
World")' and other
('throw new JsPException("Hello World",throwableObject)) fail to
display "Hello World"?

Thnaks for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,607
Members
45,240
Latest member
pashute

Latest Threads

Top