A user leaves an online shopping cart without checking out.Which of the following interfaces will notify to rollback the transaction?

A user leaves an online shopping cart without checking out.Which of the following interfaces will notify to rollback the transaction?
a)HttpSession
b)HttpSessionBindingListener
c)HttpServlet
d)SingleThreadModel
e)FtpSession

Questions by ravikumar3

Showing Answers 1 - 9 of 9 Answers

It will be HTTPSessionBindingListener which can be used to notify the rollback to the transaction. This interface has an unbound method which can be overridden to perform the above functionality

  Was this answer useful?  Yes

phanikhk

  • Apr 9th, 2008
 

Any class can implement HttpSessionBindingListener interface. This interface includes two methods, valueBound() and valueUnbound(), that are called whenever the object that implements the interface is bound or unbound from a session.

Typical example could be - you might want to close the dbconnection if it is unbound from session.

class MyConnectionHolder implements HttpSessionBindingListerner

  Connection dbCon;

  public MyConnectionHolder(Connection con) {
    dbCon = con;
  }

  public void valueBound(HttpSessionBindingEvent event) {
    // Do nothing
  }

  public void valueUnbound(HttpSessionBindingEvent event) {
    dbCon.close();
  }
}

  Was this answer useful?  Yes

(b)HttpSessionBindingListener is the correct answer

valueBound() and valueUnbound() are the methods that should be over-ridden to get this implemented.

Thanks.
Vinay

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions