dcsimg
Problem using IO functionality within a bean within a JSP page
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Andrew_Harrison
Posted On:   Tuesday, June 5, 2007 09:53 AM

Hello Can you please help. I am a new user of Netbeans 5.5. I've managed to setup a project successfully and the application is working well with one exception. AIM: All I am trying to achieve is to list the relative directories of my web application in order to traverse through these files to pick up images to build an image gallery. PROBLEM: When I run the JAVA class as a standalone I get the expected result. Output points to my application root directory as expected: . uild . uild.xml .conf .dist . bproject .src    More>>


Hello



Can you please help.



I am a new user of Netbeans 5.5. I've managed to setup a project successfully and the application is working well with one exception.



AIM:


All I am trying to achieve is to list the relative directories of my web application in order to traverse through these files to pick up images to build an image gallery.



PROBLEM:


When I run the JAVA class as a standalone I get the expected result.



Output points to my application root directory as expected:



. uild

. uild.xml

.conf

.dist

.
bproject

.src

. est

.web




But when I try to import this class as a bean into my JSP page it points to the bin directory of the Tomcat server (C:Program Files
etbeans-5.5enterprise3apache-tomcat-5.5.17 in) instead and I get the file listing:




. ootstrap.jar

.catalina-tasks.xml

.catalina.bat

.catalina.sh

ETC... ETC...



I realise that this is probably a simple relative path configuration that I've missed, but my understanding of server setup is limited and would really appreciate a simple explanation on how to have the bean point to the
relative path of my web application as it did as a standalone java class.



This is something I expected Netbeans to automatically configure as everything else works out-of-the-box.




For a simple demo of my problem I've created the following cutdown file examples:






I would be very grateful for any input into this matter.



Andrew Harrison

   <<Less

Re: Problem using IO functionality within a bean within a JSP page

Posted By:   Robert_Lybarger  
Posted On:   Tuesday, June 5, 2007 06:54 PM

You may want to look into (and I'll botch this being somewhat from memory) calling application.getAbsolutePath("/") (yeah, the implicit JSP page variable) to have it return a String for the server-side path that corresponds to that webapp's context-relative "/" URL. Then build a File object and continue as you're doing. If that method call isn't right, its fairly close -- my IDE generally autocompletes when I'm close enough. ;-) And google is also your friend.
About | Sitemap | Contact