I have implemented the OpenSessionInViewFilter for my MVC webapp and it works almost perfect. Only problem is that it also creates a session for every image, js, css etc that are requested from the webserver. This i dont want.
Im using struts2, spring and hibernate and this is my web.xml
<filter>
<filter-name>lazyLoadingFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>lazyLoadingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
So because i am mapping url-pattern /* it also takes all the images etc.. I tried setting it to *.jsp, and *.action, but then i get the lazyloading-exceptions again... How should i do this? I've been looking for answers for 5 hours now and im getting a litle bit crazy in my head.
All i need to do is to make this filter IGNORE all the static resources. Thats it! And for everything else it can run. It sounds so simple, but its really really annoying me that i cant figure out how.
Any help would be greatly appriciated.
Do i need to extend the filter to write my own filter and exclude within it? And if so. How?
EDIT: It seems like i could set up filter-mappings for my static files at the top of the filter-chain. And then send those to a "ByPassFilter", thus bypassing the filterchain for these static resources. Is this the way to go??
Thanks guys!