K
kaeli
Hey all,
I have a little problem. My error page (JSP) seems to not be getting the
exception text for some reason when my beans throw exceptions in the setters
and I use setProperty. The errors do fine when I use other methods. This is
the only case in which they aren't working.
Here's the setup. Can someone tell me what I'm doing wrong?
In the bean: (many similar methods; this one is generic for illustrative
purposes)
public void setField(String str) throws IllegalArgumentException
{
// limit 10 chars (null allowed)
if (str!= null && str.length() > 10)
{
throw new IllegalArgumentException(
"Field must be 10 characters or less.");
}
this.field = str;
}
In the JSP:
<%@ page isErrorPage="false" errorPage="err.jsp" %>
....
<jsp:useBean id="myBean" class="myPackage.myBean" scope="page" />
<jsp:setProperty name="myBean" property="*" />
<% myBean.testUpdate(s.getPerms()); %>
Err.jsp (note that "exception" is an intrinsic JSP object, like "out")
<p class="bigAttention">Message: <%= exception.getMessage() %></p>
When exceptions are thrown from the testUpdate method in the bean, they
forward just fine to err.jsp. When thrown from the setters, I get null when I
try exception.getMessage (or just JasperException when I do toString).
Sample from using toString:
---------------------------------
Message: org.apache.jasper.JasperException
Stack Trace: org.apache.jasper.JasperException at
org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper
(JspRuntimeLibrary.java:199) at
---------------------------------
When testUpdate fails:
---------------------------------
Message: This operation requires permissions. You either have VIEW
permissions or aren't logged in. Please LOG IN if you haven't, then try
again.
Stack Trace: java.lang.IllegalAccessException: This operation requires
permissions. You either have VIEW permissions or aren't logged in. Please LOG
IN if you haven't, then try again. at
---------------------------------
When I used getMessage, it was similar, but Message was null instead of
JasperException.
WTF?
Anyone?
--
I have a little problem. My error page (JSP) seems to not be getting the
exception text for some reason when my beans throw exceptions in the setters
and I use setProperty. The errors do fine when I use other methods. This is
the only case in which they aren't working.
Here's the setup. Can someone tell me what I'm doing wrong?
In the bean: (many similar methods; this one is generic for illustrative
purposes)
public void setField(String str) throws IllegalArgumentException
{
// limit 10 chars (null allowed)
if (str!= null && str.length() > 10)
{
throw new IllegalArgumentException(
"Field must be 10 characters or less.");
}
this.field = str;
}
In the JSP:
<%@ page isErrorPage="false" errorPage="err.jsp" %>
....
<jsp:useBean id="myBean" class="myPackage.myBean" scope="page" />
<jsp:setProperty name="myBean" property="*" />
<% myBean.testUpdate(s.getPerms()); %>
Err.jsp (note that "exception" is an intrinsic JSP object, like "out")
<p class="bigAttention">Message: <%= exception.getMessage() %></p>
When exceptions are thrown from the testUpdate method in the bean, they
forward just fine to err.jsp. When thrown from the setters, I get null when I
try exception.getMessage (or just JasperException when I do toString).
Sample from using toString:
---------------------------------
Message: org.apache.jasper.JasperException
Stack Trace: org.apache.jasper.JasperException at
org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper
(JspRuntimeLibrary.java:199) at
---------------------------------
When testUpdate fails:
---------------------------------
Message: This operation requires permissions. You either have VIEW
permissions or aren't logged in. Please LOG IN if you haven't, then try
again.
Stack Trace: java.lang.IllegalAccessException: This operation requires
permissions. You either have VIEW permissions or aren't logged in. Please LOG
IN if you haven't, then try again. at
---------------------------------
When I used getMessage, it was similar, but Message was null instead of
JasperException.
WTF?
Anyone?
--