You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Viral_Thakkar <Vi...@infosys.com> on 2003/10/27 10:21:21 UTC

how to access HttpSession in EJB code?

Is there any way, I can access the object from session in the EJB bean method?

I am keeping the profile object in HttpSession, once the user gets successfully logged-in. Now I want to access few values from this profile object which is kept inside session.

The application flow is as below :

Struts Action --> Business Delegate --> Session Façade...

Thanks,
Viral


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


Re: how to access HttpSession in EJB code?

Posted by Kirk Wylie <kw...@m7.com>.
There is a pass-by-reference system available in most EJB containers, 
but it's proprietary for each server, so you almost certainly don't want 
to use it for this purpose (it's there as a performance optimization, 
not to make doing in/out parameters easier).

Kirk Wylie
M7 Corporation

Andrew Hill wrote:
> (Im not actually an EJB expert but heres what I know. Hopefully if I get it
> wrong someone will correct me quickly!)
> 
> It would need to be passed back via the methods return value.
> 
> When you call the EJB method the parameters are serialized over to the 
> ejb -
> so the ejb code will be working with a different instance (if the EJB is
> local to the same JVM as its caller it may be a different matter but one
> shouldnt just assume one is making a local call).
> 
> Afaik the EJB container will not serialize back any changes made to the
> passed objects when the call completes - unless of course those objects are
> part of the return value. The return value object will of course be
> serialized back.
> 
> -----Original Message-----
> From: Greg Dunn [mailto:greg.dunn@mo.nisc.cc]
> Sent: Wednesday, 29 October 2003 00:58
> To: Struts Users Mailing List; andrew.david.hill@gridnode.com
> Subject: RE: how to access HttpSession in EJB code?
> 
> 
> I was having difficulty with something like the reverse of this.  If you
> pass the object to your EJB (or in my case a task scheduler), which then
> updates it, is there any way to pass it back to store the updated 
> version in
> context?
> 
> Greg
> 
> 
> -----Original Message-----
> From: Andrew Hill [mailto:andrew.david.hill@gridnode.com]
> Sent: Monday, October 27, 2003 3:29 AM
> To: Struts Users Mailing List
> Subject: RE: how to access HttpSession in EJB code?
> 
> 
> Hi Viral,
> You will need to get the required object from the session up in the p-tier
> and pass it to your ejb in a method parameter when you call the EJB (or
> facade to it).
> (The EJB layer doesnt know about servlets and such like (indeed its client
> might well not be a servlet app)).
> -Andrew
> 
> -----Original Message-----
> From: Viral_Thakkar [mailto:Viral_Thakkar@infosys.com]
> Sent: Monday, 27 October 2003 17:21
> To: Struts Users Mailing List
> Subject: how to access HttpSession in EJB code?
> 
> 
> Is there any way, I can access the object from session in the EJB bean
> method?
> 
> I am keeping the profile object in HttpSession, once the user gets
> successfully logged-in. Now I want to access few values from this profile
> object which is kept inside session.
> 
> The application flow is as below :
> 
> Struts Action --> Business Delegate --> Session Façade...
> 
> Thanks,
> Viral
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


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


RE: how to access HttpSession in EJB code?

Posted by Andrew Hill <an...@gridnode.com>.
(Im not actually an EJB expert but heres what I know. Hopefully if I get it
wrong someone will correct me quickly!)

It would need to be passed back via the methods return value.

When you call the EJB method the parameters are serialized over to the ejb -
so the ejb code will be working with a different instance (if the EJB is
local to the same JVM as its caller it may be a different matter but one
shouldnt just assume one is making a local call).

Afaik the EJB container will not serialize back any changes made to the
passed objects when the call completes - unless of course those objects are
part of the return value. The return value object will of course be
serialized back.

-----Original Message-----
From: Greg Dunn [mailto:greg.dunn@mo.nisc.cc]
Sent: Wednesday, 29 October 2003 00:58
To: Struts Users Mailing List; andrew.david.hill@gridnode.com
Subject: RE: how to access HttpSession in EJB code?


I was having difficulty with something like the reverse of this.  If you
pass the object to your EJB (or in my case a task scheduler), which then
updates it, is there any way to pass it back to store the updated version in
context?

Greg


-----Original Message-----
From: Andrew Hill [mailto:andrew.david.hill@gridnode.com]
Sent: Monday, October 27, 2003 3:29 AM
To: Struts Users Mailing List
Subject: RE: how to access HttpSession in EJB code?


Hi Viral,
You will need to get the required object from the session up in the p-tier
and pass it to your ejb in a method parameter when you call the EJB (or
facade to it).
(The EJB layer doesnt know about servlets and such like (indeed its client
might well not be a servlet app)).
-Andrew

-----Original Message-----
From: Viral_Thakkar [mailto:Viral_Thakkar@infosys.com]
Sent: Monday, 27 October 2003 17:21
To: Struts Users Mailing List
Subject: how to access HttpSession in EJB code?


Is there any way, I can access the object from session in the EJB bean
method?

I am keeping the profile object in HttpSession, once the user gets
successfully logged-in. Now I want to access few values from this profile
object which is kept inside session.

The application flow is as below :

Struts Action --> Business Delegate --> Session Façade...

Thanks,
Viral


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


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



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


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


RE: how to access HttpSession in EJB code?

Posted by Greg Dunn <gr...@mo.nisc.cc>.
I was having difficulty with something like the reverse of this.  If you
pass the object to your EJB (or in my case a task scheduler), which then
updates it, is there any way to pass it back to store the updated version in
context?

Greg


-----Original Message-----
From: Andrew Hill [mailto:andrew.david.hill@gridnode.com]
Sent: Monday, October 27, 2003 3:29 AM
To: Struts Users Mailing List
Subject: RE: how to access HttpSession in EJB code?


Hi Viral,
You will need to get the required object from the session up in the p-tier
and pass it to your ejb in a method parameter when you call the EJB (or
facade to it).
(The EJB layer doesnt know about servlets and such like (indeed its client
might well not be a servlet app)).
-Andrew

-----Original Message-----
From: Viral_Thakkar [mailto:Viral_Thakkar@infosys.com]
Sent: Monday, 27 October 2003 17:21
To: Struts Users Mailing List
Subject: how to access HttpSession in EJB code?


Is there any way, I can access the object from session in the EJB bean
method?

I am keeping the profile object in HttpSession, once the user gets
successfully logged-in. Now I want to access few values from this profile
object which is kept inside session.

The application flow is as below :

Struts Action --> Business Delegate --> Session Façade...

Thanks,
Viral


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


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



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


RE: how to access HttpSession in EJB code?

Posted by Andrew Hill <an...@gridnode.com>.
Hi Viral,
You will need to get the required object from the session up in the p-tier
and pass it to your ejb in a method parameter when you call the EJB (or
facade to it).
(The EJB layer doesnt know about servlets and such like (indeed its client
might well not be a servlet app)).
-Andrew

-----Original Message-----
From: Viral_Thakkar [mailto:Viral_Thakkar@infosys.com]
Sent: Monday, 27 October 2003 17:21
To: Struts Users Mailing List
Subject: how to access HttpSession in EJB code?


Is there any way, I can access the object from session in the EJB bean
method?

I am keeping the profile object in HttpSession, once the user gets
successfully logged-in. Now I want to access few values from this profile
object which is kept inside session.

The application flow is as below :

Struts Action --> Business Delegate --> Session Façade...

Thanks,
Viral


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


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