1

For example:

<constant name="struts.multipart.saveDir" value="temp" />

will save to:

\Apache Tomcat 7.0.14\bin\temp\upload__781d3178_13831f5e207__8000_00000003.tmp

So, instead, how do I make it go to:

C:\my_project\build\web\temp\

Without using the absolute file path because I don't want to reconfigure it each time the project moves. I just want the relative path basically.

EDIT 1:

I don't think it matters, but I'm using Struts 2 version 2.1.8.1

EDIT 2:

I'm using Apache Tomcat. That's where I'm deploying the project to. Is there no way to make a reference to Tomcat's project deployment location in the struts.xml?

Something like:

<constant name="struts.multipart.saveDir" value="..\webapps\project\build\web" />

2 Answers2

0

The project is where the sources of the application, on the developer workstation, are.

At runtime, all you got is a server running a deployed war. The sources of the application, and the directory where they are on your workstation are irrelevant for the app server. It doesn't care, and doesn't have to know. There might be such a directory on the app server machine, but it's not sure, and it's a directory as all the other directories on the machine. There is no other way than specifying it in some config file.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • No, it's not possible. But using a relative path, like you're already doing will lead to a folder relative to the tomcat installation directory. – JB Nizet Jun 28 '12 at 10:42
  • How doesn't it work? Does this directory exist? Have you tried with forward slashes instead of backslashes? Why do you put project/build/web in the webapps directory of tomcat? It's supposed to contain war files or exploded war directories. – JB Nizet Jun 28 '12 at 10:54
  • Could you possibly just show me how it's supposed to be? Like just drop a 1 liner from a working example? I think that might be easier. –  Jun 28 '12 at 11:00
  • You have a one-liner in your own question: you use `temp` as the value of the property, and files end up in `\Apache Tomcat 7.0.14\bin\temp\`. So the directory is relative to tomcat's `bin` directory. – JB Nizet Jun 28 '12 at 11:07
0

there are several ways to do this. here is the most easy way:

<constant name="struts.multipart.saveDir" value="${catalina.home}/webapps/project/web/temp"/>

you have to set your CATALINA_HOME

UPDATE

maybe this way, in your web.xml:

<context-param>
  <param-name>catalina.home</param-name>
  <param-value>path/to/your/tomcat</param-value>
</context-param>

UPDATE

I also found a link, it is for Log4j, but it is the same. Link-To-Solution

Community
  • 1
  • 1
Jaiwo99
  • 9,687
  • 3
  • 36
  • 53
  • Jaiwo99 to the rescue as always! haha thanks man. The only problem is that when I'm developing locally then the project gets deployed to `c:\project\build` and when I deploy it on the server then it goes to `catalina.home\webapps\project\build` –  Jun 28 '12 at 11:12
  • @ThreaT hehe, then cool! `build` folder only exists in your development enviroment, it wouldn't appear in your app later. – Jaiwo99 Jun 28 '12 at 11:15