I'm using GWT widget to upload my files, I'd like to upload them under tomcat folder on Ubuntu server, so I need to set the param value for this piece of code in web.xml:
<context-param>
<description>Location to store uploaded file</description>
<param-name>file-upload</param-name>
<param-value>
...
</param-value>
</context-param>
If I try to set http://ip.ip.ip.ip:8080/var/lib/tomcat7
it returns UploadActionException
and e.getMessage()="http://ip.ip.ip.ip:8080//var//lib//tomcat7"
.
It seems that Eclipse try to search this path in my Window filesystem. Any ideas to resolve this? Thanks.
http://ip.ip.ip.ip:8080/var/lib/tomcat7 is not the same thing as /var/lib/tomcat7 on your server. To use that as the upload directory put this init-param in your upload servlet declaration in web.xml
<context-param>
<description>Upload Directory</description>
<param-name>upload-directory</param-name>
<param-value>/var/lib/tomcat7</param-value>
</context-param>
and then in the upload servlet build a path string starting with
String dirPath = getServletContext().getInitParameter("upload-directory");
then write the FileItem to a file like this
File file = new File( dirPath + "/" + fileItem.getName());
fileItem.write(file);
All of this would require the whole directory /var/lib/tomcat7 to be writable by whatever user tomcat is running under which is a bad idea. But there you have it.