|
-
Jan 23rd, 2009, 11:04 AM
#1
Thread Starter
Hyperactive Member
Java Web Application Absolute/Relative Path
Hi,
I developed JSP using Netbeans (Apache Tomcat). I need to write out a file into a my project folder instead of the apache tomcat folder if I did not specify any path.
I tried out.println(getServletContext().getRealPath("")); and it gives the path
C:\Users\user\Desktop\project\build\web
.
How is it possible for me to change it to
C:\Users\user\Desktop\project\web folder?
Please advice, cheers
-
Jan 23rd, 2009, 07:33 PM
#2
Re: Java Web Application Absolute/Relative Path
This is the problem with your type of hobbiest programmers. Netbeans doesn't run the project from it's current location.. It deploys the web app to Apache tomcat and tries to launch it then. So, your application isn't actually in your C:\...\Desktop, hence the path C:\...\Desktop\... is an absolute path
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jan 24th, 2009, 01:44 AM
#3
Thread Starter
Hyperactive Member
Re: Java Web Application Absolute/Relative Path
Oh I see, so for this case, is it possible to enter the path correctly by using java built in method like getServletContext().getRealPath("") ?
As this project is shared by different user, so when it is move to other PC, the path is different if I type my absolute path.
As the getServletContext().getRealPath("") command return me C:\Users\user\Desktop\project\build\web, I would like to change it to
C:\Users\user\Desktop\project\web instead, so I wonder is there other method I can use to achieve that or I must use substring to manually edit the path?
Please advise
-
Jan 24th, 2009, 05:22 AM
#4
Re: Java Web Application Absolute/Relative Path
If the file you're trying to point to is in the Netbeans project then you must know Netbeans deploys everything in the project to the Server
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jan 25th, 2009, 07:53 AM
#5
Thread Starter
Hyperactive Member
Re: Java Web Application Absolute/Relative Path
oh ok thanks for the information
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|