I've done this in the past within an ActionForm like so: this.servlet.getServletContext()
Craig. <tataryn:craig/> On Mon, 15 Mar 2004 10:40:09 -0500, "Saul Q Yuan" wrote: > > I am not sure you can get the session directly in the form bean, > however, you can get the current session in your action class, and in > your action class, try get the current user and set it in the form bean. > > > -----Original Message----- > > From: Amish Patel [mailto:[EMAIL PROTECTED] > > Sent: Sunday, March 14, 2004 11:13 PM > > To: [EMAIL PROTECTED] > > Subject: Re: Multibox and selected values > > > > > > Saul, > > > > How can I access the current user from the form bean? The > > current user is > > in the session. So in other words my question is how can I > > access the > > session from the form bean? > > > > Thanks in advance for your help! > > > > > > > > >From: "Saul Q Yuan" <[EMAIL PROTECTED]> > > >Reply-To: "Struts Users Mailing List" > > <[EMAIL PROTECTED]> > > >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > >Subject: Re: Multibox and selected values > > >Date: Sun, 14 Mar 2004 20:42:31 -0500 > > > > > >If I understand your questions correctly, you can define two String > > >arrays > > >in your form bean, one for allRoles, and the other for > > selectedRoles, which > > >is the array of roles of the current user. Before forwarding > > to your jsp, > > >in your action class, you can retrive all the roles of the > > currently user, > > >and set the roles to the selectedRoles in the form bean. > > > > > >HTH, > > >Saul > > > > > > ----- Original Message ----- > > > From: Amish Patel > > > To: [EMAIL PROTECTED] > > > Sent: Sunday, March 14, 2004 11:59 AM > > > Subject: Multibox and selected values > > > > > > > > > Hello All, > > > > > > I am running into this problem, that I am not able figure > > out how to > > >do > > >it > > > properly. I have searched the web and have not found a > > decent example. > > > What I am trying to do is use html:multibox taglib to > > display a set of > > > checkboxes. These check boxes represent the user's security > > >preferences. > > > So if the user has a particular security token, then the > > respective > > >check > > > box should be checked. > > > > > > In order for this to work properly, I have to get two > > things, all the > > > security tokens that exits in the system. And I have to get the > > >security > > > tokens that the user already has. In my ActionForm, I > > have two methods: > > > one that gets all the security tokens in the system and > > second that gets > > > only the tokens that the user has. The following is > > what I am using in > > >my > > > jsp to display checkboxes. > > > > > > <logic:iterate name="associateUserRoleForm" property="allRoles" > > > id="element"> > > > <html:multibox property="selectedRoles"> > > > <bean:write name="element" /> > > > </html:multibox> > > > <bean:write name="element" /> > > > <br /> > > > </logic:iterate> > > > > > > > > > Right now I am able to get allRoles successfully, but in order to > > >retrieve > > > the selectedRoles, I need a way such that my ActionForm > > > (associateUserRoleForm) can get hold of this user or this > > user's id, > > >which > > > is already in the session. Once I get this I can then > > display all the > > > security tokens and check those tokens that the user already has. > > > > > > How can I do this? Am I on the right track or is there a > > better way > > >to > > >do > > > this? > > > > > > Thank You very much for your help! > > > -Semplice > > > > > > _________________________________________________________________ > > > Get business advice and resources to improve your work life, from > > >bCentral. > > > http://special.msn.com/bcentral/loudclear.armx > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > _________________________________________________________________ > > Find things fast with the new MSN Toolbar - includes FREE > > pop-up blocking! > > http://clk.atdmt.com/AVE/go/onm00200414ave/direct/01/ > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] <tataryn:craig/> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]