Java Serializable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • whitep8
    New Member
    • Oct 2009
    • 65

    Java Serializable

    Hi All,

    Can anybody give me a useful suggestion as to how i could use serializable in a simple, non GUI, netbeans driven book lending system? this would consist of only users, books and loans

    I dont want any code, just ideas to get my head around how to use it in.
  • jx2
    New Member
    • Feb 2007
    • 228

    #2
    You can use serialize in many ways, i.e. instead of database system ;-) I wouldn't recommend it
    any way it would look something like that:
    Code:
    class book implements serializable{
     String isbn;
    String author;
    //geters and setters here
    }
    then you can save it on hd as an object there is nice example on wikipedia: http://en.wikipedia.org/wiki/Serialization
    regards
    jan

    Comment

    • pjerald
      New Member
      • Oct 2007
      • 77

      #3
      "serializab le" is a machanism used to pass an object to a remote server.

      Consider a Hashtable or Hashmap object which has some keys and values in a java program. And you need to send this object(Note: See you need the whole object) to a remote server, how you do this?

      Remember you cannot pass hashtable object as a parameter(Try this) via http request or response.

      When you do integration with some web sites, you will be in need of sending objects instead of xmls or a json file as input/arguments.

      In this situation, you have to serialize the object(write the object) in the response in order to send it to the remote server. Got it?


      In your "book lending system", use this serialization mechanism where ever you need to write the object(as object not as a string or text) in a file.

      Comment

      • whitep8
        New Member
        • Oct 2009
        • 65

        #4
        so i could simply use a database to have tables of data, but then rather than have sql make the relational inserts, i could save the object of the loans in an object file?

        Comment

        • swacidware
          New Member
          • Oct 2009
          • 2

          #5
          For socket,

          To make the transaction secure, you may create an object that implements Serializable that will hold all necessary data for processing, override the uid value with any values that only you who knows about it. and to verify if it is coming from the client or worker, all you have to do is to cast the received object if it is the data carrier object or not... even if someone tries to replicate the object and used to send a malicious data to the server, you can still filter it, unless they know the uid value

          Comment

          Working...