Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why Serialization is used  RSS feed

 
Raja ji
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why serilization is used?
Actually i am developing a web based application using Servlet and JSP.Is serialization used for this application?

I know that there are two techniques of using serialization :-
(1) By implementing Serilizable interface and using classes ObjectOutputStrem and ObjectInputStream for writing and reading objects in files.

(2) By implementing Serilizable interfce only
and not using both clsses.

I want to ask in which situation we should use techniques (1) and for which situation we should use techniques (2).
and for my application which one is better and why?
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Serialization is required if you want to persist your objects to secondary storage like disk or send the objects across the network. For an object to be serializable it must inplement Serializable interface. ObjectOutputStream and ObjectInputStream are used to write the serializable objects to file.

(1) and (2) mentioned by you are not alternatives.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!