H All,
I am trying to create a login application using servlets and using sessions for storing the login info. the login info is stored in a hashmap. as the server restarts, the info is lost. So i m trying to write this info in Temp file. So that the info will not lost on server restart.
This is the code
File tempDir = (File)getServletContext().getAttribute("javax.servlet.context.tempdir");
File tempFile = File.createTempFile(getServletName(), ".tmp", tempDir);
FileWriter fw= new FileWriter( tempFile );
fw.write(uname);
fw.write(pword);
Where uname and pwords are the login info of the user.
When the user logs in for the first time he need to enter username, password and confirm password. And the username and password get store in the hasp map.
The above code creates a temp file, but the login info is lost on server restart. Can anybody help?
Also, when the user clicks browser back button after Logout, he is able to access the 'login required page'. Can somebody help me with logout method?
A code snippet will be most highly appreciated.
Thanks