I'm not sure if your code works Alex - but this is how I do it (so I know it
works)

Context ctx = new InitialContext();
Object homeObject = context.lookup("UserSession");

UserSessionHome home =
(UserSessionHome)PortableRemoteObject.narrow(ctx.lookup("ejb.UserSession",
UserSessionHome.class);

UserSession us = home.create(); // the portable remote object is not needed
here, only for lookups I believe

HttpSession s = request.getSession(true);
s.putValue("userSession", us);

to retrieve

UserSession us = (UserSession)s.getValue("userSession"); // not get,
getValue()


At the worst it's another (shorter) alternative way to code it ;)

Cheers,
Mike

 __
|  | Director - The BookmarkBox P/L
|  |  http://www.bookmarkbox.com <http://www.bookmarkbox.com/>
|/\| Manage and share your bookmarks online!

Do you enjoy our service? Why not tell your friends about us?
http://www.bookmarkbox.com/email.cfm


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Alex Paransky
> Sent: Sunday, 26 December 1999 9:10
> To: Orion-Interest
> Subject: RE: Adding a Session bean to an HttpSession
>
>
> First you would actually use the home interface to create your UserSession
> like so:
>
> Context context = new InitialContext();
> Object homeObject = context.lookup("UserSession");
> UserSessionHome home =
> (UserSessionHome)PortableRemoteObject.narrow(homeObject,
> UserSessionHome.class);
> UserSession us = (UserSession)
> PortableRemoteObject.narrow(home.create(<argumentsGoHere>),
> UserSession.class);
>
> Now, you can use your other code to set the values in:
>
> HttpSession sess = request.getSession(true);
> sess.putValue("$SESSION$", us);
>
> ... later ...
>
> HttpSession sess = request.getSession(true);
> UserSession us = (UserSession) sess.get("$SESSION$");
>
> Hope this helps.
> -AP_
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Frank Apap
> Sent: Saturday, December 25, 1999 12:14 PM
> To: Orion-Interest
> Subject: Adding a Session bean to an HttpSession
>
>
> Could someone show me some example code for how to add a session
> bean to an
> HttpSession?  This is the psuedo-code for what i want to do ....
>
> --//UserSession is a Session EJB
>
> UserSession us = new UserSession();
> us.setName("MYNAME");
> HttpSession sess = request.getSession(true);
> sess.add(us);
>
>
>
> I know this code is wrong, but I am looking for what the actual code to do
> this would be.
>
> Thanks...
>
>

Reply via email to