It has a package 'main' with a class that should write the objects to file.
The class that writes the objects has a main method which can be run to test the objects get written, which they do.
Essentially I have the code,
Which creates the testFile.ser file at the root of the project.
But when I run the web-app locally, the file isn't written.
I'm thinking I need to adjust the path, like "/testFile.ser" or something, but this doesn't work.
Can anyone help? Thanks
Bear Bibeault
Author and opinionated walrus
Marshal
You have no control over what the "current directory" is within a web app. So using relative file paths is fraught with danger. Use an absolute file path.
So I guess this applies when I upload project to server, I should use:
www.mywebsite.com/projectName/testFile.ser
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12612
posted
0
When you upload, your servlet (or whatever) should write the stream somewhere outside the web application. It avoids accidental deletions on a redeploy, and is the *only* option when deploying a war file.
colin shuker
Ranch Hand
Joined: Apr 11, 2005
Posts: 706
posted
0
Hi, so I'm using an absolute path, and it works fine locally, but when I upload to server and run web-app:
So I tried setting the file permissions on the BankApp folder to allow everything, but it makes no difference.
I believe I have to do something with a policy file, but I don't know where it goes.
Basically I create my war file with netbeans 6.9, upload to server using Tomcat 6, and I get it deployed.
You're trying to write to a web address. That's not going to work. You still need the actual disk location.
colin shuker
Ranch Hand
Joined: Apr 11, 2005
Posts: 706
posted
0
Thanks, but I don't get it, I donno what that location is
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12612
posted
0
http:// is the HTTP protocol. You can't just write arbitrary files to a web app.
The web app should take the uploaded file and write it somewhere known to the web app (we have no way of knowing where that would be on your system) using an absolute path.
colin shuker
Ranch Hand
Joined: Apr 11, 2005
Posts: 706
posted
0
Thanks, but I got no idea..
On the server, the top directory is web-root I think.
I just put the path as "BankAppFolder/ABC.ser", where BankAppFolder is in the same directory as the war file.
I donno if it works yet, cause it takes time for them to reload it. Thats why I don't really want to reload it 50 times trying different paths, was hoping someone could point me in the right direction.
Thanks for any help.
Lester Burnham
Rancher
Joined: Oct 14, 2008
Posts: 1337
posted
0
As Bear said, in web apps you can't use relative paths (Like "BankAppFolder/ABC.ser"), so you need to figure out what the correct absolute path is. If you're not sure what that is, ask the server admin.
colin shuker
Ranch Hand
Joined: Apr 11, 2005
Posts: 706
posted
0
Thanks, I asked them, the path was
/home/colinjava/web-root/BankAppFolder/ABC.ser
and this works, seems hard work writing web-apps, always something wrong or not working, or thats probably just me