• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data Transfer Object

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic