• Post Reply Bookmark Topic Watch Topic
  • New Topic

Handling Permissions on Web Applications  RSS feed

 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have been thinking, is there any alternative to giving permissions on web applications?
I basically been doing this for some time.

1. On successfull login, I store the privileges for the user on a map



2. To check if he has access to certain forms, I check the map values for key. Set the disabled attributes
if he has none.


Now, if this is such a long form.. and you check the generated HTML, you will see a lot of space between form tags.

I have been thinking, is there an alternative to this?

P.S. I just use scriptlet here for clarity reason. (I know Mr. Bibeault will come here and yell at me, 'hey your app is 90's' if I am still doin this)
I type this in also without checking if this will work.
Just wanted to get others advice or get some idea on how others implement this type of logic.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Don't use scriptlets!

2. You don't need to repeat the entire HTML over and over again. If the disabled attribute is all that varies, just conditionalize it. The EL's ternary operator can be helpful here.

3. You wrote "and you check the generated HTML, you will see a lot of space between form tags. " So?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also wouldn't use keys like "1", "2" ...

In fact, I wrote this article about using Maps in scriptless JSPs way back in the Ice Ages that uses permission checking as an example.

 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also wouldn't use keys like "1", "2" ...


Already made the changes...

In fact, I wrote this article


Very nice article. A bit dated but still very useful. Already integrated the steps in my web apps..

Thanks so much, guru!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!