 <p>I solved the problem . But there is a bunch of work to do . So I write down here one by one ;</p> <ol> <li><p><strong>Session.getServletContext().getRealPath("Index.jsp");</strong> is not true . But not the main problem . in the brackets we must write a folder not a file to find the parent folder. After correct this, it will return null again . because Java EE 7 does not support getRealPath() method. but at the end this will be already solved by changing the version.</p></li> <li><p>On Netbeans IDE , at toolbar , tools >> Servers , I removed the tomcat server. and also uninstall the Apache Tomcat8 that comes with Netbeans8 because there may be a version problem as I read from the forums.</p></li> <li><p>And I download Apache Tomcat7 from the official site of apache and installed service.</p></li> <li><p>I configured tomcat-users.xml config file for admin priviledges.</p></li> <li><p>And I add the Tomcat7 server at netbeans from the same toolbar (tools >> Servers)</p></li> <li><p>What I saw was in the project the server was not there. I went inside project properties , from the menu > Run , and Server combo-box was empty. Because I was using Java EE7 and Tomcat7 needs at least Java EE6. So I needed to change the java ee version.</p></li> </ol> <p><strong>What to do :</strong> Click the files tab near projects tab. Under nbproject folder , select j2ee.platform , for Tomcat7 change the platform to 1.6 (Tomcat6 > Jave EE 1.5). than make a "clean and build" on the project . Now the server will come at Project > properties > Run > Servers</p> <ol start="7"> <li>After that I came across with another problem : (And also you may :) ) Tomcat logs from NetBeans says : </li> </ol> <p>-<strong>" '127.0.0.1*' is not recognized as an internal or external command "</strong></p> <p><strong>to correct that :</strong> <a href="http://stackoverflow.com/questions/26485487/error-starting-tomcat-from-netbeans-127-0-0-1-is-not-recognized-as-an-inter">Error starting Tomcat from NetBeans - &#39;127.0.0.1*&#39; is not recognized as an internal or external command</a></p>