Creating a Class in EJB and using it in my Struts Forms.


Please look here:

At present i have 3 JSP's, 2 Form-Bean and 2 Form-Action as follows:

     JSP                       Form-Bean               Form-Action
  ------------              -----------------         -------------------
 ShowList.jsp                   ---                             ---

ShowList.jsp includes FilterList.jsp and RegisterList.jsp

At the bottom, you can see a list of members.

Q is : *I want to populate a colleciton of members with dummy objects and return it from inside the EJB.*

I was adviced by girinois as:
Just create the EJB (obtain the home interface) and then call the remote method on the EJB. In one of the remote methods pass an array or a vector of the dummy objects you have. Then do the processing you want in the EJB.

I am a new-bie for EJB and Struts... Could anyone give me some code hints...

Thanks for reading.
Who is Participating?
It depends on what you want to do inside your EJB. Do you want to create the list in there or create the list somewhere else, pass it in the EJB, do your processing and then return the result. Since you already have an action form you might as well create the list in the action form although you might as well create it in the EJB. A solution would be to pass the HttpSerlvetRequest object but this is tend to avoid this.

What I suggest is that you might want to take a look here: for integrating EJBs and struts, go through the sample code, understand what's going on and then come back to here and ask a question again? I think it is a good tutorial and will give you a basic understanding fo what's going on using ejbs and struts.
Mayank SAssociate Director - Product EngineeringCommented:
>> I want to populate a colleciton of members with dummy objects and return it from inside the EJB

I would assume that you want to create the list of members inside the EJB. You just need to code it like any normal method which returns a Collection (if you wanna use Collections). Do you want help with writing code to obtain the home interface, etc?

Which server are you using?

Make sure that anything which is passed to the EJB or returned from it is serialized.
sangeethaAuthor Commented:
thanks for your replies. sorry for being late.
The article was good, but i find it bit difficult to copw up with home interface, remote interface, etc...

Could you please explain me how and when to use home interface/remote interface. I am using JBoss server.

all the tutorials are too advanced for my java knowledge.

thanks again.
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Mayank SAssociate Director - Product EngineeringCommented:
Hi Sangeeta,

Try a basic tutorial first -

I agree with mayankeagle, read a tutorial on EJBs first: it will you give you an understanding of what's going on.
Mayank SAssociate Director - Product EngineeringCommented:
sangeethaAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.