Well, one way to do it:

1. Retrieve the user id from the request object in, e.g., LoginAction:
  Integer userId = new Integer( request.getAttribute( "userId"));
  (The userId should be an int corresponding to a primary key in your user
database table.)

2. Use the userId to pull the user data from your database via JDBC and
assign data variables with the values retrieved from the ResultSet:
  String fName = rs.getString( "fName");
  String lName = rs.getString( "lName"):
  etc. 

3. Put the user data into a Map:
  Map userData = new HashMap();
  userData.put( "fName",fName);
  userData.put( "lName",lName);
  etc.

4. Stick the Map into session scope and name it according to the userId:
  request.getSession().setAttribute( "[userId]", userData);

5. In the action class associated with the appropriate form bean, extract
the userData and set your bean properties:
  Map userData = new HashMap((Map) request
                                   .getSession()
                                   .getAttribute( "[userId]"));
  UserBean userBean = new UserBean();
  userBean.setFName( (String) userData.get( "fName"));
  userBean.setLName( (String) userData.get( "lName"));
  etc.

The associated JSP's fields should then be populated with the data.


Mark

-----Original Message-----
From: Struts Newsgroup [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 25, 2002 2:55 PM

I would like to retrieve some information I have stored in Session in an
Action Form Bean. So that I can use it within the form.

I have stored user information in session and need to know the user id to
help in populating another form bean that is used in populating a JSP.

I am using Struts v1.02.

Any help in the best way to do this would be appreciated.

Thanks,

Ken

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to