You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Schalk <sc...@volume4.co.za> on 2003/07/23 14:21:04 UTC
[FileUpload 1.0] Error in compiling to value passed to write()
Hey there
I have been using the Jakarta FileUpload package for a while now. I recently
downloaded the 1.0 binary package and are having some problems in compiling
my Servlets due to the write() method.
if(item.getName().equals("")) {
System.out.println("forwarding");
} else {
fileName = item.getName();
fileFieldName = item.getFieldName();
StringTokenizer tokenizer = new StringTokenizer(fileName, "\\,
:, /");
int amount = tokenizer.countTokens();
for (int i = 0; i < amount -1; i++) {
tokenizer.nextToken();
}
String currentFile = tokenizer.nextToken();
item.get();
item.write(folder + currentFile);
item.delete();
If someone can have a look at the code above and let me know if you can see
where the error is.
Kind Regards
Schalk Neethling
Volume4.Development.Multimedia.Branding
emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email:schalk@volume4.co.za
web: www.volume4.co.za
RE: [FileUpload 1.0] Error in compiling to value passed to write()
Posted by Schalk <sc...@volume4.co.za>.
Brian
Thanks very much
Kind Regards
Schalk Neethling
Volume4.Development.Multimedia.Branding
emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email:schalk@volume4.co.za
web: www.volume4.co.za
:: -----Original Message-----
:: From: Brian Cook [mailto:bcook@printtime.com]
:: Sent: Wednesday, July 23, 2003 6:31 PM
:: To: Jakarta Commons Users List
:: Subject: Re: [FileUpload 1.0] Error in compiling to value passed to
write()
::
::
:: That will vary depending on the servlet container you are using. Tomcat
:: writes to the Tomcat root directory. You will need to review the
:: java.io.File API to customized the directory you want it writen to.
::
::
:: ---------------------------------------------------------------------
:: To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
:: For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [FileUpload 1.0] Error in compiling to value passed to write()
Posted by Brian Cook <bc...@printtime.com>.
That will vary depending on the servlet container you are using. Tomcat
writes to the Tomcat root directory. You will need to review the
java.io.File API to customized the directory you want it writen to.
RE: [FileUpload 1.0] Error in compiling to value passed to write()
Posted by Schalk <sc...@volume4.co.za>.
Brian
The servlet now compiles but, what I am wondering is where the file be
written to? How do I tell the write method not only which file to write but
also the location to which it must be written.
Kind Regards
Schalk Neethling
Volume4.Development.Multimedia.Branding
emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email:schalk@volume4.co.za
web: www.volume4.co.za
:: -----Original Message-----
:: From: Brian Cook [mailto:bcook@printtime.com]
:: Sent: Wednesday, July 23, 2003 6:02 PM
:: To: Jakarta Commons Users List
:: Subject: Re: [FileUpload 1.0] Error in compiling to value passed to
write()
::
::
:: Example:
:: File fullFile = new File(item.getName());
:: File savedFile = new
:: File(getServletContext().getRealPath("/"),fullFile.getName());
:: item.write(savedFile);
::
::
::
:: Brian
::
:: At the top of the code I create:
:: Public String folder = "folder to which file is to be saved";
::
:: The issue for me is after calling item.get() (item being FileItem) how do
I
:: pass this file to the write() method to write it to disk. In the past I
:: used:
:: Item.write(folder + currentFile); where currentFile's value is
:: item.getName();
::
:: Kind Regards
:: Schalk Neethling
:: Volume4.Development.Multimedia.Branding
:: emotionalize.conceptualize.visualize.realize
:: Tel: +27125468436
:: Fax: +27125468436
:: email:schalk@volume4.co.za
:: web: www.volume4.co.za
::
::
:: :: -----Original Message-----
:: :: From: Brian Cook [mailto:bcook@printtime.com]
:: :: Sent: Wednesday, July 23, 2003 5:21 PM
:: :: To: Jakarta Commons Users List
:: :: Subject: Re: [FileUpload 1.0] Error in compiling to value passed to
:: write()
:: ::
:: :: Where is "folder" defined and instantated? What type of object is it?
:: ::
:: :: The API shows that it will except objects of type java.io.File only
:: ::
:: ::
:: :: API for FileItem write method:
:: ::
:: :: void write(java.io.File file)
:: :: A convenience method to write an uploaded item to disk.
:: ::
:: ::
:: :: ---------------------------------------------------------------------
:: :: To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
:: :: For additional commands, e-mail: commons-user-help@jakarta.apache.org
::
::
::
:: ---------------------------------------------------------------------
:: To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
:: For additional commands, e-mail: commons-user-help@jakarta.apache.org
::
::
::
::
::
:: ---------------------------------------------------------------------
:: To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
:: For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [FileUpload 1.0] Error in compiling to value passed to write()
Posted by Brian Cook <bc...@printtime.com>.
Example:
File fullFile = new File(item.getName());
File savedFile = new
File(getServletContext().getRealPath("/"),fullFile.getName());
item.write(savedFile);
Brian
At the top of the code I create:
Public String folder = "folder to which file is to be saved";
The issue for me is after calling item.get() (item being FileItem) how do I
pass this file to the write() method to write it to disk. In the past I
used:
Item.write(folder + currentFile); where currentFile's value is
item.getName();
Kind Regards
Schalk Neethling
Volume4.Development.Multimedia.Branding
emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email:schalk@volume4.co.za
web: www.volume4.co.za
:: -----Original Message-----
:: From: Brian Cook [mailto:bcook@printtime.com]
:: Sent: Wednesday, July 23, 2003 5:21 PM
:: To: Jakarta Commons Users List
:: Subject: Re: [FileUpload 1.0] Error in compiling to value passed to
write()
::
:: Where is "folder" defined and instantated? What type of object is it?
::
:: The API shows that it will except objects of type java.io.File only
::
::
:: API for FileItem write method:
::
:: void write(java.io.File file)
:: A convenience method to write an uploaded item to disk.
::
::
:: ---------------------------------------------------------------------
:: To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
:: For additional commands, e-mail: commons-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
RE: [FileUpload 1.0] Error in compiling to value passed to write()
Posted by Schalk <sc...@volume4.co.za>.
Brian
At the top of the code I create:
Public String folder = "folder to which file is to be saved";
The issue for me is after calling item.get() (item being FileItem) how do I
pass this file to the write() method to write it to disk. In the past I
used:
Item.write(folder + currentFile); where currentFile's value is
item.getName();
Kind Regards
Schalk Neethling
Volume4.Development.Multimedia.Branding
emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email:schalk@volume4.co.za
web: www.volume4.co.za
:: -----Original Message-----
:: From: Brian Cook [mailto:bcook@printtime.com]
:: Sent: Wednesday, July 23, 2003 5:21 PM
:: To: Jakarta Commons Users List
:: Subject: Re: [FileUpload 1.0] Error in compiling to value passed to
write()
::
:: Where is "folder" defined and instantated? What type of object is it?
::
:: The API shows that it will except objects of type java.io.File only
::
::
:: API for FileItem write method:
::
:: void write(java.io.File file)
:: A convenience method to write an uploaded item to disk.
::
::
:: ---------------------------------------------------------------------
:: To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
:: For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [FileUpload 1.0] Error in compiling to value passed to write()
Posted by Brian Cook <bc...@printtime.com>.
Where is "folder" defined and instantated? What type of object is it?
The API shows that it will except objects of type java.io.File only
API for FileItem write method:
void write(java.io.File file)
A convenience method to write an uploaded item to disk.
RE: [FileUpload 1.0] Error in compiling to value passed to write()
Posted by Schalk <sc...@volume4.co.za>.
This issue was resolved, thanks.
Kind Regards
Schalk Neethling
Volume4.Development.Multimedia.Branding
emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email:schalk@volume4.co.za
web: www.volume4.co.za
:: -----Original Message-----
:: From: Rosdi Kasim [mailto:rosdi@epantai.com.my]
:: Sent: Friday, July 25, 2003 11:00 AM
:: To: Jakarta Commons Users List
:: Subject: Re: [FileUpload 1.0] Error in compiling to value passed to
write()
::
::
:: what is the error message?
::
::
:: ----- Original Message -----
:: From: "Schalk" <sc...@volume4.co.za>
:: To: <co...@jakarta.apache.org>
:: Sent: Wednesday, July 23, 2003 8:21 PM
:: Subject: [FileUpload 1.0] Error in compiling to value passed to write()
::
::
:: Hey there
::
::
::
:: I have been using the Jakarta FileUpload package for a while now. I
recently
:: downloaded the 1.0 binary package and are having some problems in
compiling
:: my Servlets due to the write() method.
::
::
::
:: if(item.getName().equals("")) {
::
:: System.out.println("forwarding");
::
:: } else {
::
:: fileName = item.getName();
::
:: fileFieldName = item.getFieldName();
::
::
::
:: StringTokenizer tokenizer = new StringTokenizer(fileName,
"\\,
:: :, /");
::
:: int amount = tokenizer.countTokens();
::
:: for (int i = 0; i < amount -1; i++) {
::
:: tokenizer.nextToken();
::
:: }
::
:: String currentFile = tokenizer.nextToken();
::
::
::
:: item.get();
::
:: item.write(folder + currentFile);
::
::
::
:: item.delete();
::
::
::
:: If someone can have a look at the code above and let me know if you can
see
:: where the error is.
::
::
::
:: Kind Regards
::
:: Schalk Neethling
::
:: Volume4.Development.Multimedia.Branding
::
:: emotionalize.conceptualize.visualize.realize
::
:: Tel: +27125468436
::
:: Fax: +27125468436
::
:: email:schalk@volume4.co.za
::
:: web: www.volume4.co.za
::
::
::
::
::
:: ---------------------------------------------------------------------
:: To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
:: For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [FileUpload 1.0] Error in compiling to value passed to write()
Posted by Rosdi Kasim <ro...@epantai.com.my>.
what is the error message?
----- Original Message -----
From: "Schalk" <sc...@volume4.co.za>
To: <co...@jakarta.apache.org>
Sent: Wednesday, July 23, 2003 8:21 PM
Subject: [FileUpload 1.0] Error in compiling to value passed to write()
Hey there
I have been using the Jakarta FileUpload package for a while now. I recently
downloaded the 1.0 binary package and are having some problems in compiling
my Servlets due to the write() method.
if(item.getName().equals("")) {
System.out.println("forwarding");
} else {
fileName = item.getName();
fileFieldName = item.getFieldName();
StringTokenizer tokenizer = new StringTokenizer(fileName, "\\,
:, /");
int amount = tokenizer.countTokens();
for (int i = 0; i < amount -1; i++) {
tokenizer.nextToken();
}
String currentFile = tokenizer.nextToken();
item.get();
item.write(folder + currentFile);
item.delete();
If someone can have a look at the code above and let me know if you can see
where the error is.
Kind Regards
Schalk Neethling
Volume4.Development.Multimedia.Branding
emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email:schalk@volume4.co.za
web: www.volume4.co.za