Sunday, July 9, 2017

11. An EJB application that demonstrates Session Bean (with appropriate business logic).

1. Select file -> new project -> java EE -> Enterprise Application -> next -> give project name
and project location -> next -> select glassFishServer -> Select all EJBModule,
WebApplicationModule and finish.
2. It will create ejb,war with project folder.
3. Right click on project-ejb and select new-> session bean -> give EJBName, location,package
and
session type (stateless)& select local interface. It will create java files like projectname.java,
local.java
4. Right click inside projectname.java page -> click insert code -> add business method -> and
define
business methods.
method : add
returnType:int
param1:int -a
param2:int-b (Press OK)
5. change in add method return (a + b)
6. Create a servlet by right clicking the war file and select -> new servlet, give name and location
-> next -> accept the servletname and URL pattern(s) fields and click finish.
7. Right click on the content of servlet session and select insert code then select callEnterprise
Bean -
> Select sessionBean -> click ok.
8. Add the following line in the end of try block
out.println("Addition :" + sessionBeandemo.add(10, 20));
9. Set the relative URL of the project -> right click the project folder -> select properties -> run -
>
select display browser on run relative URL /MyServlet -> OK.
10. Build and run the project

No comments:

Post a Comment