JSTL: How to avoid scriptlet for JDBC connection close?
posted 13 years ago
I'm trying to convert a JSP to use JSTL and the Expression Language without scriptlets. The JSP instantiates a bean and then uses the EL to invoke several getter routines. The bean opens a JDBC connection when the first getter is called, and stores the connection in an instance variable since it will be needed by subsequent getters. My problem: How can I close the JDBC connection at the end of my page without using a scriptlet? Right now I have this at the bottom of all my pages: <% bean.close(); %> where the bean's close() method closes the JDBC connection. Is there a better way to do this? I suppose I could change the name of close() to look like a getter routine, and invoke that from the Expression Language, but that seems incredibly kludgy.