EJB programming & troubleshooting: EJB transaction when http request canceled

  1. EJB transaction when http request canceled (3 messages)

    Hi, I would like to know what will happen to EJB transaction when http request is canceled by user. Let me explain the situation. I have separate Servlet layer and EJB service layer. Both layers are on WebLogic. A user clicked a submit button in Web browser, the request came to Servlet layer, and passed to EJB layer. Here EJB service was updating our database. At this point, if the user clicks 'Stop' or 'Back' button in web browser, or closes the browser, then what will happen in EJB side? Will the update transaction be rollbacked? Or, the update will be completed and committed? Can anyone please let me know the answer? Thanks
  2. Hello, The transaction will continue. After the request comes to the servlet, the processing can't be stopped by the user. The server has no idea what the user is doing. The only result of clicking "Stop" or "Back" is that the user will not see the generated response.
  3. Thank you for your answer. I got another question now. What happens if the Servlet layer throws an exception? The transaction in EJB side will be rollbacked? Let me explain my question with a sample code. Suppose the following is part of Servlet code: Servlet { Call EJB service (); Do something, but got RuntimeException, so that user screen will be 500 internal error, for example } Will the transaction in EJB side be rollbacked or completed? Thanks again.
  4. Unless you explicitly start your transaction in the servlet, the transaction will start and commit as the thread enters and leaves the ejb container. So, if an exception is thrown after the ejb invocation, whatever data manipulation ocurred in the ejb will remain committed. /Niklas