You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ruimo Uno <ru...@gmail.com> on 2007/08/16 12:34:34 UTC

Open session in view question.

Hi,

I'm trying to implement 'open session in view pattern' using Struts2
and feeling difficulties.
First, I have prepared the following interceptor:

    public String intercept(ActionInvocation invocation) throws Exception {
        Strung ret = null;
        try {
            ret = super.intercept(invocation);
            // commit();
        }
        catch (Throwable ex) {
            // rollback();
            ex.printStackTrace();
        }
        finally {
            // close();
        }
        return ret;
    }

It works fine. Once the action throws exception, the transaction
rollback is performed. But if an exception is thrown within the JSP
page, JSP itself handle the exception like this (this is Tomcat6
case):

    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null)
_jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }

As a result, the intercepter cannot receive the exception. I feel
difficulty to solve this issue if the view is constructed by JSP.
Any idea will be appreciated.

Thanks,

-- 
Ruimo Uno
(Shisei Hanai)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org