Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not sure where serialized objects are written to in Tomcat.

 
Kris Alle
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've serialized an object and called writeObject from the doGet in a servlet. But there is no sign of this object on the file system. Any idea where the serialized object is written to on Tomcat for a webapp?

There is no exception, my assumption is it is being written somewhere, but not sure where to.

Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly how did you specify the File to use when serializing the object?

If you just used a file name without a path, Java used the "current" directory.

Bill
 
Kris Alle
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are right. I just used the filename instead of a path, hoping that it would be written to the wtpwebapps directory on tomcat server or a temp location on server or a directory within the webapp itself.

I was using OS X and surprisingly found the file at the default path which is /Users/<username>/Downloads/eclipse/Eclipse.app/Contents/MacOS

FileOutputStream fileOut = new FileOutputStream("Filename.ser");
ObjectOutputStream oos = new ObjectOutputStream(fileOut);
oos.writeObject(registerData);

Thanks
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never use relative paths in a web app, there's no predicting where they'll be written to.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic