Currently each jsp page is grabbing a connection from a general utility bean, passing that connection into each bean used by the jsp, then (sometimes) closing that connection off at the end of the jsp page.
Shiver and shudder...... Using a connection (i.e. database access straight from your screen?!) in a jsp makes me always shiver.
and the jsps could just do the following...
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext .xml");
If you want your application to come to a grinding halt after x request/pages this is the way to go...
Simply let the ContextLoaderListener load your application context ONCE then use the WebApplicationContextUtils to get just that application context and reuse it.
Code:
ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(application);
So is this right? Would the connections still get closed by Spring?
No. Spring isn't under control here so will not close anything for you.
The datasource bean would be pretty much empty.
mynewds.java
public class mynewds extends JdbcDaoSupport{}
Why would you need a bean?! Why not get the configured datasource directly instead of creating yet again a new class....
The best way to go is to implement a correct MVC pattern, however you are under some constraints as you already mentioned.
What I would do is eliminate that datasource/connection grabbing from the jsp and make all of those legacy beans spring configured beans. Then instead of retrieving the datasource and putting it inside your legacybean in the jsp, simply retrieve the legacy bean from the applicationContext. Configure datasource and transactions in your application context and spring will manage the connections for you.
If you have more time at hand it is probably a next step to modify your legacy beans to use the JdbcTemplate instead of working with the DataSource/Connection directly.