In our J2EE application, we use a EJB-3 stateful bean to allow the front code to create, modify and save persistent entities (managed through JPA-2).
It looks something
Because there is no way to know "when" the client is done with the session (extended scope).