This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Following is a quote from "Hibernate in Action" book:
<quote>The job of the servlet filter is to close the Session before the response is sent to the client (and after all views are rendered and actions are executed).</quote>
Is this approach feasible? As I understand, container invokes a filter BEFORE forwarding to a controller servlet. Can filters be invoked AFTER servlets and JSP pages finish their work to commit work and close Hibernate Session?
A filter sees the request BEFORE the servlet is called and the response AFTER the call returns from the servlet so the answer is yes. Take a look at the doFilter method in the javax.servlet.Filter interface. Bill