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.
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.