my dog learned polymorphism
The moose likes Struts and the fly likes Difference between DTO and ActionForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Difference between DTO and ActionForm" Watch "Difference between DTO and ActionForm" New topic

Difference between DTO and ActionForm

sudha javvadi
Ranch Hand

Joined: Mar 23, 2007
Posts: 97
Hi all,

Could anybody tell me the difference between dto and actionform. Do we need to use both of them in a application. I am doing some sample programs, so far I didn't use dto. In realworld what is the best practise?

Thank you,
SCJP 1.5
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
ActionForms are coupled to your view.

DTO, or 'Data Transfer Objects' are a common object that is transfered between layers.

ie getting an object out of the database, you won't have an ActionForm, you'll have a different object. If you wanted to display that object on a JSP you would transfer the values to the ActionForm and render the page (well, I wouldn't, but I'm not going to make this complicated).

In the other direction, if you were going to save something to a database from a web form. You'd take the values off of the ActionForm, put them on a DTO and send it on its way to your service layer (well, again arguable if you have some sort of facade or other layer, but speaking basically).
I agree. Here's the link:
subject: Difference between DTO and ActionForm
It's not a secret anymore!