Re: EJBs vs. Servlets ?!

Discussion in 'Java' started by Will Hartung, Aug 16, 2004.

  1. Will Hartung

    Will Hartung Guest

    "Razvan" <> wrote in message
    news:...
    > Hello,
    >
    > When someone should be using EJBs and when servlets ?
    > Are servlets just the Sun's lost children ?! They were just an
    > intermediate step before EJBs came out ?
    >
    > The only reason I see to use servlets instead of EJBs is if do not
    > have an application server (like JBOSS).
    >
    > Are there any other reasons ? (like performance, development time &
    > effort etc)


    Servlets are the primary technology in java used to interface with the Web.
    If you are talking to HTTP clients, you will, at some point, encounter a
    Servlet.

    You can obviously write custom code to listen for HTTP requests on a port
    and do with them what you will, but that would basically be folly and the
    reinvention of a lot of wheels. By working within the Servlet specification
    and within modern Servlet containers, you can do a lot of productive things.

    You can implement request logic within a Servlet, or you can simply use the
    Servlet as an interface to that logic. The logic can be implemented as Java
    classes wrapped by the Servlet, for example.

    EJBs are more geared toward creating distributed application logic. If there
    is a compelling reason to have your application logic physically seperate
    from the your presentation logic, then EJBs will fill that role. Note the
    key word "physically", as in the application logic is running on a seperate
    machine.

    A VAST majority of Web applications simply do not need this kind of
    seperation. While most application can profit from a logical seperation of
    application and presentation, far fewer benefit from the physical seperation
    requiring the added complexity and performance hit of a network hop.

    In a application that requires only a local application logic, logically
    seperated from the presentation versus physically seperated, EJBs can lose
    much of their charm and their complexity can override any real benefits
    provided by the EJB container. This realization has come from the use and
    creation of the new, "lightweight" frameworks, like Spring. These frameworks
    offer many of the advantages of an EJB container, but with lower complexity.
    However, for those application that truly need what EJB containers do offer,
    these frameworks will not fit the bill. However, again, those applications
    are much more rare.

    If you're integrating disparate systems, EJB is a good solution. But if
    you're simply writing an "everyday" web app, Servlets and any of the leading
    frameworks implemented on top of them will probably better serve your needs.

    Regards,

    Will Hartung
    ()
    Will Hartung, Aug 16, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick May
    Replies:
    3
    Views:
    327
    Sudsy
    Aug 19, 2003
  2. bebonights
    Replies:
    0
    Views:
    343
    bebonights
    Oct 13, 2003
  3. Vjeran Marcinko

    EJBs as active components?

    Vjeran Marcinko, Oct 16, 2003, in forum: Java
    Replies:
    5
    Views:
    479
    Emanuel Bulic
    Oct 17, 2003
  4. Frank Ratzlow
    Replies:
    3
    Views:
    608
    John C. Bollinger
    Nov 11, 2003
  5. Razvan

    Re: EJBs vs. Servlets ?!

    Razvan, Aug 14, 2004, in forum: Java
    Replies:
    11
    Views:
    1,043
    Christophe Vanfleteren
    Aug 16, 2004
Loading...

Share This Page