You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Fogleson, Allen" <al...@daugherty.com> on 2005/04/14 04:21:50 UTC

RE: accessing session variables in java Bean(In business logicLayer)

There isn't a "good" way to do this in my opinion other than by passing
the values to the bean class. IMHO (and probably most others) things
that tie you to the view technology (such as javax.servlet.*) shouldn't
be present in the model. Maybe no one will ever create a swing client
that calls your model but what if they did? :)

I would just pass the required variable(s) into the bean.

Al

-----Original Message-----
From: Mallik [mailto:mallikkomma@yahoo.com] 
Sent: Wednesday, April 13, 2005 9:01 PM
To: Struts Users Mailing List; Martin Gainty
Subject: Re: accessing session variables in java Bean(In business
logicLayer)

I can use  getSesssion and setSession in the action class but I need to
access
session variable in my java bean where I perform my business logic, not
in
action class methods. (java beans are called from action class). I hope
I am
clear this time.

Thanks,
Mallik


--- Martin Gainty <mg...@hotmail.com> wrote:
> struts-config identifies a forward to an identifier
> The identifier is associated with the implementted action Class
> The action class contain execute methods which reference 
> HTTPServletRequest/HTTPServletResponse parameters
> which can getSesssion and setSession for whatever parameter you desire
> Is there something specific you want?
> Martin-
> ----- Original Message ----- 
> From: "Mallik" <ma...@yahoo.com>
> To: <us...@struts.apache.org>
> Sent: Wednesday, April 13, 2005 8:08 PM
> Subject: accessing session variables in java Bean(In business logic
Layer)
> 
> 
> > 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: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


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