Q:

I do not see the directory created ,while trying from a servlet . Why is that?

The following is a servlet that attempts to create a directory and a text file inside that directory.
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    String s = request.getServletContext().getRealPath("/");
    PrintWriter out = response.getWriter();
    FileMaker fm  = new FileMaker();
    fm.makeDirectoryTester();
}

Class that makes a directory and a text file in it :
public void makeDirectoryTester() {
    try {
        File f = new File("FlushTester/");
        if(!f.exists()) {
            boolean b = f.mkdir();
            System.out.println("Directory Made (Inside makeDirectoryTester) --> " + b);
            PrintWriter writer = new PrintWriter("FlushTester/TESTER.txt");
            writer.println("This is the first statement");
            writer.println("This is the second statement");
            writer.println("This is the third statement");
            writer.close();
        }
    }catch(Exception exc) {
        exc.printStackTrace();
    }
}

The problem is that the boolean f.mkdir() returns true but I cannot see any directory created or any file inside it ! Why is that ? I am using tomcat as the server. What could be the reason for this ?

A:

If you use File f = new File("FlushTester/"); the file is relative to the start point of your application. For tomcat that is usually the bin directory.
If you need it in some other place you should use absolute path (probably configured somehow), or a path relative to your tomcat's bin directory.

