aspose file tools*
The moose likes Beginning Java and the fly likes serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "serialization" Watch "serialization" New topic
Author

serialization

jignesh soni
Ranch Hand

Joined: Dec 10, 2007
Posts: 150
why do we need to serialize an object ?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19785
    
  20

To store it on the hard disk, or send it through the network mostly.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
jignesh soni
Ranch Hand

Joined: Dec 10, 2007
Posts: 150
I need more detais with a scanario and underlying mechanism to understand this concept. If I am sending a query, then it goes through HTML page, at the other end it is received by servlet, servlet transfers the query to database thr JDBC and the result is displayed by JSP. Where does Serialization come in picture in the process ?

Pls explain
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Originally posted by jignesh soni:
Pls explain

Please use real words when posting to the forums. Abbreviations such as "pls" in place of "please" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Originally posted by jignesh soni:
Where does Serialization come in picture in the process ?

It doesn't. In the scenario you described, no object serialization takes place.
jignesh soni
Ranch Hand

Joined: Dec 10, 2007
Posts: 150
can you please explain in what scenario, serialization will come in play ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Personally, I've never found a need to use serialization directly in my 10 years of Java programming. But I have used technologies that use it under the covers. For example, when using RMI, serialization is used to send data over the network. Or when replicating a servlet session across a cluster, the objects in the session are serialized.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11499
    
  16

you can write code so that when your process shuts down, it serializes some objects, and saves them to your disk drive. then, a day, a week, a year later, you restart your process. you read the file, and can re-create the objects and have them be in the same state as before you shut down.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Abhinav Srivastava
Ranch Hand

Joined: Nov 19, 2002
Posts: 349

i have seen it being used for deep cloning.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
There is an article somewhere on the Java website about serialization and deep cloning. I think this is it. I have mentioned it before on these boards, and:
  • There is a performance overhead to using serialization like this.
  • There is a subtle difference in the results, but I can't remember what it is. Maybe the article will help. Have a look.
  •  
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: serialization