In developing my web application i have used a file to register and search data
the is stored beside the class that do the operations of reading and writing
well, when i write the name of the file as a path for it as follow
Web apps have no concept of a "default directory", so you can't use relative paths for files. You either need to use absolute paths, or -for directories inside your web app directory- use ServletContext.getRealPath(...).
Oh, now I see it's about the compiler error - "new File(...)" throws that exception, so you need to handle it properly (using a try/catch block).
If you're just using this for a learning experience (your reasoning for not wanting to involve a database), you may want to consider making the username / password either servlet init parameters, or context parameters for the web application. DO NOT DO THIS WITH A SECURE PASSWORD, but if you want to use it just for testing, this might be a good approach.
Bear's right. For an actual enterprise solution, a database (or LDAP server) is a better option.
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower