A single instance of each Action class is used to service multiple
simultaneous requests (just like a Servlet). If you want the session,
you have to pass it around (or pass the request around, from which you
can navigate to the session).

Having a no-argument getSession() method on Action would require a
unique Action instance for each request (or Action instance pooling, or
thread-local trickery).

-Max

On Wed, 2005-11-23 at 07:14 +0530, Raghu Kanchustambham wrote:
> Hi,
> I believe supporting a getSession() call is useful in the Action class.
> 
> let me walk you through a situation:
> 
> public class MyAppBaseAction extends DispatchAction
> {
>      //some helper functions
> 
>      isAuthorized( arguments )
>      {
> 
> 
>      }
> 
> }
> 
> 
> public class MyAction1 extends MyAppBaseAction
> {
> 
>       create(....)
>       {
>               isAuthorized(...)
> 
>               //restOfCode....
> 
>        }
> 
> }
> 
> 
> 
> Now in the above scenario... isAuthorized necessarily needs to be sent a
> request object as one of the parameters from which it can extract the
> session and then extract the user object from the session. This is not a
> great pain, but I think the code would look cleaner if I dont have to pass
> the request/session object around. If I had a getSession function support
> from the struts action class, then isAuthorized doesnt need to have an
> argument like Session or Request.
> 
> What do you think?
> 
> Regards,
> Raghu


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

Reply via email to