Servlets and EJBs

Discussions

Web tier: servlets, JSP, Web frameworks: Servlets and EJBs

  1. Servlets and EJBs (1 messages)

    Hello! Can anybody tell me if there is any problem when an EJB is used in a servlet? Should I take into account any "strange" thing? Thanks.

    Threaded Messages (1)

  2. Servlets and EJBs[ Go to top ]

    There's no major issues with calling an EJB from a servlet. One thing to be aware of is that servlets by nature are multi-threaded (multiple threads can run the same servlet at the same time), however a single instance of a stateful EJB bean can only handle a single thread. Somewhere you'll need to account for this threading mismatch.

    We use a servlet as a controller in our architect. It forwards the request onto a Delegate (regular java class, can be shared between users) which then accesses a synchronized Model (regular java class). The Model is single-threaded, and if need be can access stateful EJB Beans.

    Tim