"When my project is just 'Java Project' I don't have to provide the full path"
Your IDE is reading the file from working directory which is normally the project root.
"when I have the 'Dynamic Web Project', I am getting the error if I don't give the full absolute path of the file"
Web application are packaged in to a .war(.jar). Once the application is built, the files in the src are included into the class path, and should be read as such. In your case, your file was never included into the jar, as it's not a resource within the src. Even though reading the file from the file system might work on your system, no one else using the application will be able to read it.
Instead you should have your resources in the src, say a resources
package. It depends on the structure of your build, what path you should provide, but I think with a normal maven project structure (with the file in the src/main/resources/myfile.txt) and a regular java project structure (src/resources/myfile.txt) you are safe to use the following
InputStream is = getClass().getResourceAsStream("/resources/myfile.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));