0

I have a little complicated problem to explain;

I have a project that I write on Netbeans that will be used as intranet application. It was a dynamic web application. And it has some File.IO operations in it . My aim is create some files on the directory where index.html in. So I try to make the program find the directory by the code below :

     Session.getServletContext().getRealPath("Index.jsp");

But because of java version it didn't work so I used:

     Session.getServletContext().getContextPath();

Now it shows the right path on debug but not fullpath. After debug I can find my files under c:/ not under the directory where index.html in nor even nearby my projectfolder :)

So I looked at Apache folder under Programfiles under webapps and I saw that my applications folder is not there. It didn't unfold the war file actually it seems to virtualy opens it and creates a some numbered html file under temp folder . How can I make my Tomcat work like a Tomcat on a linux system and unfold the war file and find the right folder (the main web folder) and read write files, folders etc.

Additionally I want to add the server.xml unpack config below:

          <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true">

Even if you can give me a clue I would be pleased. Thanks, Kaan

K0zk
  • 21
  • 5
  • @Everv0id - you might want to clarify that statement a bit. Most web applications need at least some IO operations. – cjstehno Feb 10 '15 at 13:48

1 Answers1

0

I solved the problem . But there is a bunch of work to do . So I write down here one by one ;

  1. Session.getServletContext().getRealPath("Index.jsp"); 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.

  2. 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.

  3. And I download Apache Tomcat7 from the official site of apache and installed service.

  4. I configured tomcat-users.xml config file for admin priviledges.

  5. And I add the Tomcat7 server at netbeans from the same toolbar (tools >> Servers)

  6. 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.

What to do : 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

  1. After that I came across with another problem : (And also you may :) ) Tomcat logs from NetBeans says :

-" '127.0.0.1*' is not recognized as an internal or external command "

to correct that : Error starting Tomcat from NetBeans - '127.0.0.1*' is not recognized as an internal or external command

Community
  • 1
  • 1
K0zk
  • 21
  • 5