• Post Reply Bookmark Topic Watch Topic
  • New Topic

StreamCorruptedException vs InvalidClassException

 
seema mani
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm opening a URLConnection and writing some objects(String,Vector etc) to a servlet using ObjectOutputStream.In the servlet when I try to read it using readObject, I get
java.io.StreamCorruptedException
Version Mismatch,
Expected 5 and got 2
Now someone had suggested that this could be happening because of different JDK versions on the client and server. In my previous experiences with streams, I have got the error "java.io.InvalidClassException: Version; Local class not compatible " whenever class versions were not matching. Could anyone tell me the difference between these 2 exceptions? Which are the causes for InvalidClassException vs. StreamCorruptedException ? How do we handle StreamCorruptedException in the case of built-in classes like String and Hashtable ?
Thanks in advance
seema
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!