reset password
Author Message
rmhatre
Posts: 4
Posted 18:47 Feb 10, 2014 |

HW 02

i have users.txt file which stores registration details of new users..viz located in WEB-INF/users.txt

when users enters his/her details the above file doesn;t gets updated instead users.txt file in below location gets updated.

E:\CS 320\320workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\cs320\WEB-INF\users.txt

 

Code......

File file1 = new File(getServletContext().getRealPath(
                "/WEB-INF/users.txt"));

if (file1.exists())
            System.out.println("file found");

        BufferedWriter writer = new BufferedWriter(new FileWriter(file1, true));  

xytian
Posts: 70
Posted 19:00 Feb 10, 2014 |

Don't save the user information in a text file, use application scope instead. Otherwise when you deploy your application on CS3 it will give an exception as your directory is protected on the server.

Last edited by xytian at 10:45 Feb 11, 2014.
cysun
Posts: 2935
Posted 20:08 Feb 10, 2014 |
rmhatre wrote:

HW 02

i have users.txt file which stores registration details of new users..viz located in WEB-INF/users.txt

when users enters his/her details the above file doesn;t gets updated instead users.txt file in below location gets updated.

E:\CS 320\320workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\cs320\WEB-INF\users.txt

...

As I said in class, Eclipse does not run your project from your project folder - it deploys your project to the Eclipse work directory and run it from there.