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]

Reply via email to