• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filter and Struts

 
Calvin Kong
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • 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
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • 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.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok use application scope then.
Gill's suggestion sounds fine enough.
[ October 14, 2004: Message edited by: adeel ansari ]
 
Murthy Cherukumilli
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you so much for your help!!

Cal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic