Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Data Transfer Object

 
Rajni Patel
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to EJB. I am using EJB 3. when I click button from JSP then I want to get only one field value's arraylist from database.

for this I did EJB call. and from ejb method I call DAO class and I fetch value and store in arraylist. and that arraylist I want to print in JSP.

Now my question is, from DAO class whatever I get value, Do I need to transfer using Data transfer object, means in ejb side also create bean file and using this object I need to transfer that arraylist( means arraylist of that bean object).

or direct I can return arraylist of string type to servlet and to Jsp?

My program flow:

JSP --> servlet --> interface(ejbcall) --> class implement interface --> DAO--> return arraylist of string --> interface --> servlet--> jsp of output.

Do I need below?

JSP --> servlet --> interface(ejbcall) --> class implement interface --> DAO--> return arraylist of bean object --> interface --> servlet--> jsp of output.



Thanks in advance.
 
Kumar Raja
Ranch Hand
Posts: 547
2
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajni Patel wrote:
Now my question is, from DAO class whatever I get value, Do I need to transfer using Data transfer object, means in ejb side also create bean file and using this object I need to transfer that arraylist( means arraylist of that bean object).

or direct I can return arraylist of string type to servlet and to Jsp?


Rajni, this is merely a design decision between passing an arraylist or a custom designed object. I would use DTO or some other wrapper, if I know that I need the information to be passed around in a nice wrapper with my own functionality, which can be called upon later. In contrary, all I need is to send back the information from persistence to presenation and I'm done with that, I do not bother in creating another DTO.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!