This Tutorial explains, How to execute First EJB program in Netbeans editor. Example considers in EJB program is Simple Interest Calculations.
The Enterprise Java Bean (EJB) is a business component runs inside EJB container. The idea behind component-container model in Java EE architecture is to reduce workload of business component developer to get away from system level services development. In Java EE development business component developer should focus on writing business logic and other system level services will be taken care by EJB container. The container take care of: Instantiation, Pooling, Transactions, Security etc. EJB is designed to make applications scalable!
Create Project – EJB Program | Application
In NetBeans IDE, select ,File > New Project >Select project type under category,Java EE, Project type as Ejb Application. Click Next > button > Enter project name and location. Click Next > button > Select Server as Glassfish Application Server > Click Finish button.
Create a session EJB
Select project EJB Module in project explorer window and right click on it. Select, New > Session Bean.Select New Session Bean wizard. Enter session bean name and package name. Click Finish button. The following ejb classes created by NetBeans. following files are created stateless session bean,local interface for session bean. Insert Business method in Session Enterprise Java Bean class & Implement it.
Create a servlet – invoke business method
select ejb war module > insert servlet file > insert Session EJB Object reference > invoke business method and pass parameters.
Create JSP page – design front end and invoke servlet
select ejb war module > insert jsp file > design a front end to accept parameters > call servlet file through submit button.
Please refer video tutorial for step by step execution ejb program for simple interest calculation. you can download ejb program code of video tutorial. Download Code : TestEJBApplication2.rar (164 downloads) .
You can ask any query on email : [email protected]
Thank you !
First EJB program | EJB Application | Step by Step | EJB Tutorials | JSP | Servlet