Calling Session bean from Servlet

Discussions

EJB design: Calling Session bean from Servlet

  1. Calling Session bean from Servlet (3 messages)

    I'm calling my session bean from servlet, which approach is better:
    1) every time when I process request I should create InitialContext, do lookup, and home.create() than use the bean
    2) in servlet init(...) method create InitialContext, do lookup, and home.create() and when servlet is being requested just use that bean

    Please, do not ignore this question if it looks stupid to you -- I'm new to EJB programming.
  2. Calling Session bean from Servlet[ Go to top ]

    Hi
      We have used a singleton approach to cache bean homes.It works pretty good.Instantiate all ur ejb homes in a singleton ; and just call getEJBXXHome() to get the homes.
    Regards
    Pankaj
  3. What u said is correct . i am also using the same.

    regards,
    vasan.
  4. Calling Session bean from Servlet[ Go to top ]

    I would do what the others have said, cache the home ref. If it's a stateless session bean you can cache the remote ref. too.

    --
    Tinou
    www.tinou.com