You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Iran Marcius <ir...@isic.com.br> on 2002/11/29 11:45:28 UTC
How to perform something after authentication?
Hi. I'm using Struts with velocity-tools in tomcat-4.1.12. I got a
JDBCRealm which works uses BASIC authentication.
When a user authenticates in this realm, I need to load all his
preferences from database. How could I do that? Should I extend
ActionServlet and redefine some method ("process" or
"processPreprocess", for example)?
Could someone give me a hint about that?
Thanx in advance.
iran
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: How to perform something after authentication?
Posted by Gemes Tibor <ge...@regens.hu>.
2002. november 29. 11:45 dátummal Iran Marcius ezt írtad:
> Could someone give me a hint about that?
Create a filter, which check wheter the preferences are loaded and stored into
session. If not, load them and store:
public void doFilter(
ServletRequest req,
ServletResponse resp,
FilterChain chain)
HttpServletRequest request = (HttpServletRequest)req;
javax.servlet.http.HttpSession session = request.getSession();
UserPrefs prefs = (UserPrefs)
session.getAttribute(Constants.USER_PREFS);
if (prefs == null ) {
String username= request.getUserPrincipal().getName();
prefs = loadUsePrefs(username);
session.setAttribute(Constants.USER_PREFS, prefs);
}
chain.doFilter(req, resp);
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>