Hi,
   I have the following scenario in my web application: the request is
handled by a filter named CommitFilter. The CommitFilter simply calls
chain.doFilter(request,response) and, after that, commits the database
transaction. If there's a problem while comitting the transaction, the
CommitFilter logs the problem and throws a ServletException to alert the
user that something is wrong. Here's the code for CommitFilter:

   public void doFilter(...){
      chain.doFilter(request.response);
      try{
         transaction.commit();
      }
      catch(SQLException e){
         LOG.error("Error while committing the transaction",e);
         throw new ServletException("Error while committing the
transaction",e);
      }
   }

   The problem is: when there's a SQLException while committing, the
ServletException I throw is never displayed to the user. So the user
thinks that the transaction was correctly committed.
   After some investigation I found out that this happens because the
ServletResponse is already committed after
"chain.doFilter(request,response);" is executed. I have already tried to
use a bigger buffer in the page directive, but it didn't help because
when the page is big, 30Kb, for example, it is somehow automatically
flushed even if my page buffer is bigger (100Kb for example) and
autoFlush="false".
   My questions are:
       - how can I force the buffer to be committed only after
CommitFilter.doFilter() method is executed?
       - is there another way to solve this problem?

   I am using Tomcat 5.0.28, and my web application uses servlet
2.4/jsp 2.0 specification.
   Thank you very much. Any help would be much appreciated.

Thanks,
   Jair Jr

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com

Reply via email to