Calling A Session Bean Using A Web Module

7 April 2007

It is assumed that the reader knows how to create an Enterprise Application and to add J2EE modules into it. To know more click here. So you created an Enterprise Application and added an EJB module and a Web module to it. Here we will discuss how to call a “Session Bean” from the web module.

  1. Select the web module and select “New” -> “Servlet”.
  2. Now fill servlet specific information in the next window.
  3. Click “Next” for adding other servlet related information like “Url pattern(s)”, “Servlet Name” these details will be stored in the web.xml file, configuration file of the web module.
  4. Servlet will be added to web module with some basic code.
  5. Open the Servlet file by clicking on it. Then right click “Select Enterprise Bean”
    -> “ Call Enterprise Bean ”.
  6. A window will be displayed showing information of EJB’s in the project. Select one you want to call with referred interface, As EJB can be called remotely or locally.
  7. Click “OK”. A private method for remote lookup will be generated, so in “processRequest” method we can call that private method to return remote reference and on that EJB remote instance any of the EJB business methods can be invoked. We will invoke “sayWelcome” method that is assumed to be already added.
  8. Now right click “Enterprise Application” icon and click “Run project”. EJB and web module will be deployed automatically. If application server is not running it will also be started.
  9. In “Console” window you can see EJB has been deployed and NetBeans will automatically run the web module.
  10. Use new servlet URL to run your servlet that has code of EJB client we added. You can see the remote method results there.

del.icio.us:Calling A Session Bean Using A Web Module digg:Calling A Session Bean Using A Web Module spurl:Calling A Session Bean Using A Web Module wists:Calling A Session Bean Using A Web Module simpy:Calling A Session Bean Using A Web Module newsvine:Calling A Session Bean Using A Web Module blinklist:Calling A Session Bean Using A Web Module furl:Calling A Session Bean Using A Web Module reddit:Calling A Session Bean Using A Web Module fark:Calling A Session Bean Using A Web Module blogmarks:Calling A Session Bean Using A Web Module Y!:Calling A Session Bean Using A Web Module smarking:Calling A Session Bean Using A Web Module magnolia:Calling A Session Bean Using A Web Module segnalo:Calling A Session Bean Using A Web Module gifttagging:Calling A Session Bean Using A Web Module

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Calling A Session Bean Using A Web Module

One Response to “Calling A Session Bean Using A Web Module”

  1. Lokesh Kumar Says:

    This page help me. I also want some information about how to create JSP page and call enterprise bean into it.

Leave a Reply