struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Siggelkow <bills...@bellsouth.net>
Subject Re: initialising user settings following login
Date Tue, 04 May 2004 01:57:40 GMT
Tim Dudgeon wrote:
> I'm wanting to use container based authentication (e.g form based login) 
> with my struts app, but initialize some user settings (which will be 
> read from a database) as soon as the user succesfully logs in. Any 
> suggestions for how to best achieve this?
> 
> Thanks
> 
> Tim
Let me say, I think the filter approach is best -- the JSP/JSTL 
approaches that I reference are Model 1 and I would not use them in  a 
sizeable app.

I think the filter approach mentiioned is a good one.

Another way is to execute "request.getUserPrincipal() or 
getRemoteUser()" before every Action (either in a BaseAction or in a 
custom RequestProcessor) -- if the call returns something other than 
null than and there is not already a "User" object in the Session than 
constitute a new User object from the database and stuff it in the session.

Another approach, albeit somewhat Model 1, is to place a
<jsp:useBean id="user" type="com.foo.User">
   <jsp:setProperty name="user" property="userName" value="<%= 
request.getRemoteUser() %>"/>
</jsp:useBean>

Then in the setter object for the com.foo.User constitute the value for 
the user.

You of course could use JSTL in the <jsp:setProperty> tag or you could 
use  a <c:set> tag.

Bill Siggelkow


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message