I'd suggest that you check out Struts' support for declarative
exception handling before extending the request processor; I would
think that it will do what you need.
Joe
At 8:11 AM +0000 9/1/05, Markus Wallner wrote:
Hello!
I would like to write my own FWRequestProcessor. The reason is that
I would like
to catch some common exception in my Web application (e.g., general database
failures). Everything else is done by the superclass. The following code
basically works fine, but my problem is that I would like to add error
information for the user (what is usually done within the action with
context.addErrors(...)). So I wonder if there a way to access the
context of the
action forwarded to in the request processor?
Thanks in advance,
Markus
protected ActionForward processActionPerform(
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.apache.struts.action.Action action,
org.apache.struts.action.ActionForm form,
org.apache.struts.action.ActionMapping mapping) throws
java.io.IOException, javax.servlet.ServletException {
log.debug("processActionPerform()");
try {
return super.processActionPerform(request, response, action, form,
mapping);
} catch (Exception e) {
log.error("FWRequestProcessor caught exception: " +
e.getMessage());
Throwable ex = e;
while (ex instanceof ServletException)
ex = ((ServletException) ex).getRootCause();
if (ex instanceof HibernateException) {
ActionErrors errors = new ActionErrors();
errors.add("Persistenzfehler", new
ActionMessage("error.hibernate.general", "ApplicationListAction " +
e.getMessage()));
//
HibernateSessionFactory.getSession().connection().rollback();
// context.addErrors(errors);
ActionForward f = new
ActionForward(mapping.getInputForward());
return mapping.getInputForward();
} else if (ex instanceof SQLException) {
log.error("SQLException!");
}
log.error("throwing new ServletException()");
throw new ServletException(e);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Joe Germuska
[EMAIL PROTECTED]
http://blog.germuska.com
"Narrow minds are weapons made for mass destruction" -The Ex
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]