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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "serialization" Watch "serialization" New topic
Author

serialization

vijay shanker
Ranch Hand

Joined: Oct 26, 2007
Posts: 88
What does serialization mean?

may i sent any java object over hyper text transfer protocal request and recieve the same at server.

if there is any other way please any one tell me the things. I got to perform for same.

thanks in advance.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39435
    
  28
Serialization means breaking up an object into a Series (usually of bytes). Note that you usually leave any static members and anything marked "transient" behind. You can save the bytes in a file, or send them across a network. Don't know whether that means sending an object across the internet, but I don't see why not.
Go here, download and unzip a copy of Thinking In Java (Bruce Eckel, 3rd edition) and look at the second part of the chapter about interfaces and inner classes (I think ch 8). (There is a 4th edition, but you have to pay for that! I've got it and just looking at the chapter for about 30 seconds, I don't think that much has changed.)
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Originally posted by vijay shanker:
What does serialization mean?


Serialization is a process in which you can "serialize" or "persist" the state of an object in a permanent storage.

What are these terms mean?

persist means saving.
permanent means into a file in a disk for example.
state of an object means the data values an instance holds to get its uniqueness.

Why do you need such an action?

When you say "a state of an object", the scope of the state is existing only temporarily. that means till the time your program is in memory (memory which helps you create an object]. What if you need to hold the data values held by an object even after the program terminates?

You need to shift the data values from this memory (RAM) to another place, that could range anything which helps to get the values without the actual program which was responsible of dealing with this particular instance.

That target location should offer you the "permanent" storage. That's why this persistence came in picture and you have "serialization" to achieve this.

To read more about Serialization, you may please read the Sun's tutorials here.

Does that help?


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Originally posted by vijay shanker:


may i sent any java object over hyper text transfer protocal request and recieve the same at server.



Do you mean to ask the provision to send an object's state in a web application? Is that way you meant by HTTP in your question?
vijay shanker
Ranch Hand

Joined: Oct 26, 2007
Posts: 88
Yes Mr. Raghavan Muthu,

This is what i suppose to do.

Actually i am asked to send some database records from client to server and then i got to think of this.

What do you see about that?

Thanks;
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Originally posted by vijay shanker:


....Actually i am asked to send some database records from client to server and then i got to think of this.



Yes, thats correct. You need to prepare an object out of the database records and you can send the object to a method in the server.

You do NOT need to take care of anything except making the object you send as a 'serializable' one.
vijay shanker
Ranch Hand

Joined: Oct 26, 2007
Posts: 88
What i am doing is making an file useing ObjectOutputStream and sending that file

but at other side i mean at server side i am not able to make object using 'readObject()' method from the file i get there.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39435
    
  28
Can you serialize with a ByteArrayOutputStream and get a byte[] array and then catch it at the other end with a ByteArrayInputStream? I don't know much about that; I have never tried myself.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

I don't think you need any of those Stream objects. Just make an object in the client side as "serializable" (means, make the class implements the Serializable interface) and send that object of the class as an argument to the method in the Server.

You need to make a RMI call here.
vijay shanker
Ranch Hand

Joined: Oct 26, 2007
Posts: 88
If that is the case i got to ask you how to do that call over Http is it possible to make RMI call over Http?
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

What sort of a UI do you have? Is it a jsp rendered HTML?
If yes, then you are just wasting your time thinking about serialization.
There is no way you can use Serialization untill and unless you are really prepared to write some jazzy looking code.
[ January 02, 2008: Message edited by: Nitesh Kant ]

apigee, a better way to API!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: serialization