Netbeans puts Build in the web application "getRealPath()"

Posted on 2009-02-10
Last Modified: 2013-12-14
Dear Experts, I have a web  app build using Netbeans 6.1, Java and Tomcat 6.0. This web app I call pbuilder for productBuilder. The web app has the following structure according the "projects" view of netbeans:

     Web Pages

I want to store I my  "secure" files under admin. I put files there like "certification.xml".
Now, in the admin directory I have a file called "viewTest.jsp: with the following scriplet:

String relativePath = request.getServletPath();  //   gives value of /admin/viewTest.jsp
           relativePath = path.substring(0,path.indexOf("viewTest.jsp")); // gives /admin/
 String path = application.getRealPath(relativePath);

the value for path on my computer is "c:\netbeans\6.1\pbuilder\build\web\admin"

The problem is I have NOT stored my "certification.xml" file in this subdirectory so later on when I use path to try and find where I have "certification.xml" I get a missing file.

I also don't see build in the "pbuilder.war" distribution. Can someone explain why this is happending and best practice to get to my "admin" directory?

Thank you,
String path = application.getRealPath(path);
Question by:maxmohave

    Author Comment

    P.S., I should of read my question over once. I apologize. Again, the problem is I'm expecting that the path my all my stuff under admin will be: c:\netbeans\6.1\pbuilder\web\admin but when I run this program netbeans says my path is c:\netbeans\6.1\pbuilder\build\web\admin.

    It adds "build".  I didn't epect this, and also I don't think "build" will show in the pbuilder.war distribution.

    thanks Max
    LVL 2

    Accepted Solution

    Have you only tested this on your develment machine? when you deploy the .war file the build directory will be your only directory under webapps. but it will not have the name "build" it will probably have the path "c:\program files\tomcat 6.0\webapps\pbuilder\".

    if getRealPath() is called now the file structure for admin returned would be
     "c:\program files\tomcat 6.0\webapps\pbuilder\web\admin". you have the right idea it is just the build directory confusing you.

    deploy your war file on a different machine and read the System.out.println()'s in the tomcat log file you will understand better then.

    Author Closing Comment

    I'll use this approach.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
    How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from ( Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now