473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to write a file in the directory of a webapp..

SPG
Hi,
I have a servlet application running on tomcat.
I want to write a default config file in the root directory of the
application:

tomcat
+webapps
+myapp
+myConfig.txt

If I use new File(./myConfig.txt), then the file goes to the root of tomcat.
Ither there an easy way to find out the directory of the running app?

Cheers,

Steve
Jul 17 '05 #1
3 4590
I've got the same issue... the only work-around i found was to specify the
entire path to the file in the web.xml file as an initialization parameter
to a servlet. That obviously doesn't work for .WAR deployments, though.
Anyone else have a better solution? I'd love to hear it.

Jeff

"SPG" <st************@nopoo.blueyonder.co.uk> wrote in message
news:JK*********************@news-text.cableinet.net...
Hi,
I have a servlet application running on tomcat.
I want to write a default config file in the root directory of the
application:

tomcat
+webapps
+myapp
+myConfig.txt

If I use new File(./myConfig.txt), then the file goes to the root of tomcat. Ither there an easy way to find out the directory of the running app?

Cheers,

Steve

Jul 17 '05 #2
>
Ither there an easy way to find out the directory of the running app?

Try this one -if the WAR file is expandend

getServletContext().getRealPath("/");
Lau.
Jul 17 '05 #3
DWY
I have a similar question in that I have a .war deployed and allow users
to upload to a folder named WEB-INF/uploads. However, how can I retain
what they uploaded if I need to re-deploy the .war?

The app. server creates a new folder when deploying a .war, meaning, the
path changes and the files previously uploaded are now not in the
WEB-INF/uploads folder.

Pipo wrote:
Ither there an easy way to find out the directory of the running app?

Try this one -if the WAR file is expandend

getServletContext().getRealPath("/");
Lau.

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vasu | last post by:
Hi, I have a requirement to download a file from the web site using a client tool. Iam writing a C# program to download using WebRequest, HttpRequest, WebResponse and so on. The problem...
1
by: Erich | last post by:
Hi, everybody! I would like my WebApp (ASP.NET) writes a text-file in my Web Host, so I could download it and import it to another application. Does anybody know how can I write a text file...
4
by: Erich | last post by:
Hi, everybody! I would like that my WebApp generates a text-file in my ISP, so I could download it and import it to another application. Does anybody know how can I write a text file running...
9
by: Joe Rattz | last post by:
I can't seem to get to trace.axd. I have turned tracing on in web.config. Here is how I currently have i configured: <trace enabled="true" requestLimit="10" pageOutput="false"...
2
by: Just D. | last post by:
How can we get the currently running WebApp directory? All kinds or Request. don't work, maybe security..., the requests that work just show C:\Windows\System32, but I need the physical path of the...
2
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
Hi; We are writing an installer for our ASP.NET app and are hitting an argument over where the default directory for the app should be. Should it be (assuming standard folder layout): 1)...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
5
by: DotNetDanny | last post by:
Hello Machine: Windows Vista Business, standalone machine (no domain). Installed an old classic ASP webapplication in IIS7, running under a new app.pool with 'NETWORK SERVICE' account (using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.