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

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:

pbuilder
     Web Pages
             META-INF
             WEB-INF
              admin

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,
max
String path = application.getRealPath(path);
maxmohaveAsked:
Who is Participating?
 
-epoch-Connect With a Mentor Commented:
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.
0
 
maxmohaveAuthor Commented:
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
0
 
maxmohaveAuthor Commented:
Thankyou,
I'll use this approach.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.