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

Posted on 2009-02-10
Medium Priority
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
  • 2

Author Comment

ID: 23604840
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

Accepted Solution

-epoch- earned 2000 total points
ID: 23608686
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

ID: 31545243
I'll use this approach.

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

850 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