Thanks for the reply.
It appears your solution is for Struts1, not Struts2.
On 5/27/07, Henry F. Camacho Jr. <[EMAIL PROTECTED]> wrote:
I create a session class that tracks all my session information needed
for each user. Since you will likely be in a action object when you
want this information, you can do something like the following:
Here is my session object called SessionVars.
import javax.servlet.http.*;
public class SessionVars
{
public SessionVars()
{
}
public static void setUserID(HttpServletRequest request, Long userid)
{
request.getSession().setAttribute("user_id", (Long)userid);
}
public static Long getUserID(HttpServletRequest request)
{
Long work;
work = (Long)request.getSession().getAttribute("user_id");
if (work == null)
{
return(new Long(-1L));
}
else
{
return(work);
}
}
Now within a action you can perform something like this:
public class LogonForm extends ActionForm
{
protected String username;
protected String password;
public LogonForm()
{
}
public String getUsername() { return this.username; }
public String getPassword() { return this.password; }
public void setUsername(String un) { this.username = un; }
public void setPassword(String pw) { this.password = pw; }
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request)
{
SessionVars.setUserID(request, useridhere);
}
}
--
Henry F. Camacho Jr.
Unplugged Cities, LLC
800 Washington Ave No
Suite 501
Minneapolis, MN 55401
Fridley, MN 55432
763-235-3005 (Office)
763-257-6898 (Cell)
tknightowl (Skype)
[EMAIL PROTECTED] (email)
www.unpluggedcities.com59 (www)
KC0KUS (Amateur Radio)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]