File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Does this situation need filter? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Does this situation need filter?" Watch "Does this situation need filter?" New topic
Author

Does this situation need filter?

Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
I have menu with tabs in my web application. but those tabs are visible/accessible based on security settings. I have tab id and user id.
Right now I have created a common method at one place and calling it from various controllers and checking for the authority settings.

But is filter best choice here or the way I have implemented is ok or something else?
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

I would not use a filter for something like this.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
So how would you have handled this situation? The way I have implemented is fine?
I thought of filter because,

- Right now I am calling the method (which authenticate the user) from every controller. Should not it be called from single place, right at the door step?
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

A filter is fine for determining if the user is logged in or not, and redirecting them to a login if not.

But I thought you were talking about making on-page decisions of what to show or not.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12612
I don't see how a filter would help--don't you need to show/not-show tabs based on roles? How would that be done with a filter? I mean, it might depend on how you're storing the tabs that should be shown, but... I can't think of how a filter would help. I'd either get the tabs once at login, or show/hide them in the template based on a custom tag or something.
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
@Bear

Ok I got it.

If you want to check whether the user has access to particular forum or 'moving the post' functionality , you will check only when that action takes place not on each and every user request.

Thank you.

@David

I'd either get the tabs once at login

This is what I am doing right now. But consider this situation. X logs into the system and he has access to Y tab. but Admin logs into the system and revokes X's access to Y tab. now if X clicks on Y , then he should not be able get the access to it and should see some admin message.

but yes I can see filter is not at all a choice here but the way I am doing it is correct i.e. on demand.

Thank you.
 
IntelliJ Java IDE
 
subject: Does this situation need filter?
 
Threads others viewed
How to export filter settings from Eclipse's Problem View
Define JVM variables in WSAD
Servlet & Filter
Authirization Filter Problem
Filtering the JTree Node
IntelliJ Java IDE