0

I've an desktop application that generates a file that contains an serialized object and then it be used to load the last state from object(It saves a configuration of a neural network), I don't have any problem running the application as a desktop application, however I need to port this application to an application web, I use the java servlet to do this,but I have some problems here, when I call the method that save the serialized object this doesn't create the file so I'm not able to use it later. I need some basic examples to do this in a standard way.

If you need more information ask me.

I save the file in the following way:

FileOutputStream ostream = new FileOutputStream(namefile);
ObjectOutputStream p = new ObjectOutputStream(ostream);
p.writeObject(this);

It works in the desktop application

fers
  • 189
  • 5
  • 13
  • Servlets will behave the same way a desktop app does with regards to calling the function. So the file should be saved. Don't use a relative location. For a test choose a location which write access to servlet container and then check. – sethu Feb 12 '12 at 04:04
  • Do you get an error? If yes, post it. If no, try printing the result of `file.getAbsolutePath()` to stdout before saving to see where it is being saved to. – rodion Feb 12 '12 at 04:18
  • Yes,I get an exception,I post it: – fers Feb 12 '12 at 04:58
  • Sorry, I save the file in this way: FileOutputStream ostream = new FileOutputStream(name_file); ObjectOutputStream p = new ObjectOutputStream(ostream); p.writeObject(this); I don't get any error here, but the file doesn't create. – fers Feb 12 '12 at 06:20
  • I have no idea what your concrete problem is, but perhaps the file is not read/saved there where you *think* it is. I'd recommend to read this possibly related dupliate: http://stackoverflow.com/questions/2308188/getresourceasstream-vs-fileinputstream – BalusC Feb 13 '12 at 00:16
  • I've resolved the problem, I use the absolute path inside relative path. – fers Feb 14 '12 at 04:54

0 Answers0