Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Filter and Struts

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a problem using Filter and Struts. I have a Filter filtering all the *.jsp and *.do. In the filter, I get user's security info (if it's not load before) and stick it in the request object. I have no problem with this at the first time. In the jsp, I can call request.getAttribute() to get the security info. However, when I submit some forms or click some link, the userSecurity in the request object is lost, and next time the filter got hit, the request.getAttribute("userSecurity") is null and creating a new object by loading user info from database again.

Am I missing something? Why can't the usersecurity info be load once ONLY and sticked in the request object and keep passing?

NOTE: I can't use the session object. I know this can solve the problem but we are NOT ALLOWED to use session.

Thanks

Calvin
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is a very strange requirement, to not use the Session object.

Another option you have is maintain an application level Map of users to user security info objects. When you interecept a request by a user, try to get the security info from map first, if it is not there, only then access the database to get it, put it in the map and set it as a request attribute.

Any request attributes you set are lost when the current request is over i.e. once you have sent a response for this request.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok use application scope then.
Gill's suggestion sounds fine enough.
[ October 14, 2004: Message edited by: adeel ansari ]
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can set the scope int he struts-config to session and that should solve the problem.
 
Calvin Kong
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much for your help!!

Cal
 
You've gotta fight it! Don't give in! Read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic