Assuming you have a file named "test.txt" at the root of your webapp, you can
get the absolute path name to the file with the following code snippet in ur
interceptor.
ActionContext context = actionInvocation.getInvocationContext();
HttpServletRequest request = (HttpServletRequest)
context.get("com.opensymphony.xwork2.dispatcher.HttpServletRequest");
String completeFilename =
request.getSession().getServletContext().getRealPath("test.txt");
----- Original Message ----
From: Paul Benedict <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[email protected]>
Sent: Tuesday, August 12, 2008 6:56:24 PM
Subject: Re: Get path to the webapp
Vasyl,
The attempt is very iffy. Some things you need to know:
1) No Servlet API provides the path to your files.
2) If running in a WAR file that is never expanded, there will be no
such file directory that will exist.
3) You can use the classloader of the web context to get the root of
your web application, but that assumes #2 is false. You must be on a
file system for it to work.
Paul
On Tue, Aug 12, 2008 at 8:04 AM, Vasyl Skrypij <[EMAIL PROTECTED]> wrote:
>
> Hi all
>
> I have Struts 2.0.9
>
> I need to get the path to the directory in which my web application is
> situated during interceptor's asking. How can I do this been using
> ActionInvocation class object which passes into intercept method, or maybe i
> should try some other way?
>
> --
> View this message in context:
> http://www.nabble.com/Get-path-to-the-webapp-tp18943905p18943905.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
__________________________________________________________________
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your
favourite sites. Download it now at
http://ca.toolbar.yahoo.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]