This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Difference between DTO and ActionForm" Watch "Difference between DTO and ActionForm" New topic
Author

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,
Sudha.
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: http://aspose.com/file-tools
 
subject: Difference between DTO and ActionForm
 
Similar Threads
How to suitably use DTO with Struts?
DAO vs DTO
ActionsForms and Value Objects
struts
Hibernate and DAO pattern