All of our application state (including the user) is kept in a
separate "session" object in the business layer.  (We use a stateful
session EJB, but you could easily write your own POJO for this.)  The
web session, then, only has a reference to this session object (and a
few other view-specific variables, for tracing page history and the
like).

-- Jeff

On 4/13/05, Mallik <[EMAIL PROTECTED]> wrote:
> Hi
> I use plain java beans for model/business layer.
> I have a question regarding accessing session variables in java Beans(In model
> Layer). I can pass session variables from action class but is there any other
> way I can access session variables directly by extending any class.
> Because I need "session.userID" every time I make an insert/update in the
> database and I feel it is redundant passing session variables every time along
> with the form data(DTO) to java bean.
> 
> My example java bean code is as follows
> 
> public class DoInsertBean
> {
>         private DataSource dataSource = null;
>         public DoInsertBean(DataSource dataSource)
>         {
>                 this.dataSource = dataSource;
>         }
> 
>     public int insert(UserDTO user){
>     //Insertion into database
>     //need session variables here??
>        }
> }
> 
> Thanks,
> Mallik
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to