Tim Tim - 1 year ago 106
Java Question

How is the DTO objects transferred from client to server in spring-struts web application without implementing serializable

I have a web application developed using Spring - Struts framework deployed in tomcat 8 server. The application is hosted in only one server.

The application code is layered like

Action | BPO | DAO | DTO | EntityObject

Only few DTO classes
implements Serializable
interface where those DTO objects are being written into file using ehcache for caching state.

Do we actually need to
implement Serializable
interface for all the DTO classes?

With reference to the below link it says not necessary to implement Serializable to all the DTO classes.

DTO implementation of Serializable interface

If so how does the DTO object gets transferred from client side to server side without serialization?

Answer Source

The Serializable is used by java.io and it's needed if you want to keep the objects in session. Some other frameworks is using Serializable behind the scene to perform serialization. If you don't know where the object is serialized using java.io.Serializable you better add this interface to DTOs.

The client-side might use other serialization like JSON, XML, etc., but it doesn't affect the processes running serialization on server-side and it should be handled separately by your code or some other framework like Struts or Spring, doesn't matter.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download