• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

DB calls from Servlet Filter vs Action class

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a situation where we calls DAO in servlet filter for user authorization. During the load test we realizes that this things become bottleneck and spawn multiple threads results in crashing server environment. But when we remove this call from filter and do the same thing after chain.doFilter() method, like in Action class it does not create same problem.
What I want to know, is there a difference in handling database calls in Filter verses in POJO?

Thanks in advance.
Sudheerbabu
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A filter will be invoked for each request to the mapping for which it is configured. Why on earth would you need to authenticate the user on each and every request? Once the user is authenticated, simply indicate as such in the session and stop beating the DB to death.
 
Sudheerv Babu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wish it was just authentication but this is about authorization in the application. In our application user deals with case ids where he has access to limited number of cases. So, whenever he makes request with some case id, we check if he is authorized to play with that case_id in the filter itself which involves DB call.
My problem is it crashes server when i do this activity in the filter not anywhere else. So, wondering if web container handles it different way.

Thanks
Sudheerbabu
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, code is code. Do you observe a greater number of DB calls when there are problems than when there are not?
 
Sudheerv Babu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Number of db calls are same in both the cases. Actually, I am running load test on the application with some 500 vusers. DB queries are optimized and has no load on db. When I have this filter code which makes queries for authorization check, after a while everything slows down and throws a websphere core dump showing thread contention in websphere. DB connection pool is quite enough to handle required connections by this load test. When I move this db calls from filter to action class layer I don't see this issue. So, again wondering why this happens only when in servlet filter.

Thanks
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should make no difference whether the code runs as a filter invocation or in an action class, so I cannot account for you observations. I'm moving this over to the websphere forum for those more familiar with websphere to comment.
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic