configuring Tomcat and spring framework
add this to your web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/springConfig.xml</param-value>
</context-param>
<listener>
<description>domyslny listener dla sF</description>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
..
..
</web-app>
ok and now prepare your spring xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="dataSource" class="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://localhost:5432/dbname"/>
<property name="password" value="pass"/>
<property name="username" value="user"/>
<property name="poolPreparedStatements"><value>true</value></property>
<property name="maxActive"><value>10</value></property>
<property name="maxIdle"><value>10</value></property>
</bean>
<bean id="injectionTest" class="pl.mypck.InjectionTest">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>
read more in spring documentation about IoC and beans http://static.springframework.org/spring/docs/2.5