ASSIGNMENTS for Lab Session 8


  1. 1

    Create an "EJB Module" project in NetBeans to host two session EJBs: the fist, a stateless session EJB, must have a method bounce(String s) that just returns back the string passed as argument; the second, a stateful session EJB, must have a method addAndRead(String s) that, as it receives a string, appends it to an internal "state string", whose updated content is returned to the invoking client. Such EJBs must have remote interfaces with the described methods, placed on a separate NetBeans project.

  2. 2

    Develop a simple web application made of one single servlet, implementing an HTML page with the upper part dedicated to contain forms, and the lower part to report messages.
    Insert an HTML form to submit a message (to the servlet itself) so that it will be passed to the stateless EJB, received back, and displayed in the response page (below the form).
    Insert another HTML form with exactly the same functionality of the previous one, but targeting instead the stateful EJB; the reference to the EJB has to be kept in a field of the servlet.
    Insert yet another HTML form like the previous one, targeting exactly same the stateful EJB; the reference to the EJB in this last case has to be kept in the session object.

  3. 3

    In the servlet, wherever possible, try to get the remote reference to an EJB using CDI, or instead explicit JMDI lookup.