• Post Reply Bookmark Topic Watch Topic
  • New Topic

Filters or Listener

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this session Listener that is invoked whenever a session starts up, its job is to determine if the Session is valid, I kind of feel that this is the job of a filter, but my colleague feels different, reason we use a lot of AJAX components and whenever the Ajax components execute they also invoke the filters, which is kind of true, so i am wondering would using a sessionListener to do the job of a Filter be reasonable given the excuses i outlined above
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends on how you do the "determine if the Session is valid" task. This at least sounds like nonsensicial. Please elaborate in detail.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By "is valid" I assume you mean that you are doing an authentication check?

If so, and to me, a filter is the correct way to go.

Why would you not want to check on Ajax requests?

Is it not just as important to check authentication on Ajax requests as any other? Do you really want to open such a gaping security hole?
 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes its doing an authentication check
 
Kumar Mettu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abiodun,

With the information you provided, it appears to be a Filter's Job. Reason being you are intercepting requests before servlet processing them to validate user is authenticated. Ajax call might happen after session expired (because user is idle on the page for an hour and an action triggered Ajax call) and this would need proper session expiry notification to frontend.

Hope this helps,

Kumar.
javaswamy.blogspot.com

Abiodun Adisa wrote:Yes its doing an authentication check
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abiodun Adisa wrote:Yes its doing an authentication check

So I ask again, why do you want to leave the Ajax requests unprotected by the authentication check?
 
kapiltyagi tyagi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Edit: hijack removed]
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to javaranch.We are happy to have you here . please dont hijack the topic ,if you want to ask question,start a new topic
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"kapiltyagi tyagi " please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The use s of Listeners is taht some things like (allocating resources, destroying resources) should take place when some callback events occurs.

and the role of filter is that Intercepting / Disturbing the requests , responses , for example every request should not hit the application .

and i observed that some people

rather than trying to answer the questions are busy mentioning about the forum rules and making there presence unnecessarily.This site CEO should definitely take a serious action and removing there messages , as they look ugly as we find many of them doing the same thing for many questions.




 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RaviNada Kiran wrote:and i observed that some people ... rather than trying to answer the questions are busy mentioning about the forum rules ...

As a newcomer it would be a good idea for you to familiarize yourself with some of these rules before criticizing how they are applied. if you have issues with the way these forums are run, the Ranch Office forum is the appropriate place to air grievances, not the technical forums such as this one.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!