Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling an EJB bean from JSP

 
Muthuvel Chinnachamy
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
Can anyone help me how to call EJB bean deployed on Weblogic server from JSP. Actually the idea is to acccess the EJB bean thro Web Browser.
Thanks in advance
Muthuvel C.
 
Mayoor Patil
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After creating an instance of your bean. Either put this bean in the session or set the attribute in the request and then you will be able to use this bean in your jsp.
------------------
 
vikinsa
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Muthuvel Chinnachamy:
Dear All,
Can anyone help me how to call EJB bean deployed on Weblogic server from JSP. Actually the idea is to acccess the EJB bean thro Web Browser.
Thanks in advance
Muthuvel C.

 
vikinsa
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to first include the bean that is going to used in that JSP. I am giving an example here. I had prepared a package which contains all of the Beans.
Just add this line with all of the other imports.
<%@ page import = "user.*" %>
"user in my case was the name of that package".
Get the initial context..
InitialContext ctx = (InitialContext)EVUtil2.getInitialContext();
Look up the home..
user.RegisterUserHome regUserHome = (user.RegisterUserHome)ctx.lookup("RegisterUserHome");
Create the remote..
RegisterUser regUser = regUserHome.create() ;
Get the data from the method present in that bean
VectormemGroups = regUser.MemberGroups(OrgID, userId);
(Here MemberGroups(OrgID, userId) is one of my methods defined in that bean and expects two inputs OrgID, userId and returns memGroups vector.)
Show the information...
use the returned data type to show information.

Enjoy.
Originally posted by Muthuvel Chinnachamy:
Dear All,
Can anyone help me how to call EJB bean deployed on Weblogic server from JSP. Actually the idea is to acccess the EJB bean thro Web Browser.
Thanks in advance
Muthuvel C.


------------------
Vikas Aggarwal
Technology Associate
http://www.vikinsa.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic