I am using guice-servlet (2.0) to inject a database connection at the beginning of each HTTP request, but how can I find out when the request ends so I can close the connection?
web.xml
<filter>
<filter-name>Guice Filter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Guice Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
GuiceServletContextListener
/**
* Creates a new Database connection.
*/
@RequestScoped
@Provides
private Connection getConnection();