You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by elyes sallem <el...@gmail.com> on 2008/12/15 11:35:53 UTC
export file data using formFile
Hello,
i want to use a formfile in jsp page, where once i browse to file , i want
to laucnh directly the action, export data to this file
(without a submit button near the fromfile)
how can i make it?
Regards
Elyes.
Re: Fwd: export file data using formFile
Posted by Oscar Alvarez <li...@gmail.com>.
I think, you need to put a hiperlink or a button for start your action. Then
you need to retrieve the data from the db, generate the csv Stream or File
as you wish to call it. Then the only diference between a Servlet.doGet
method an Action.execute method is 2 parameters ActionMapping and
ActionForm, then you need to put the Roberts example source code.
If you need more details go to this URL:
http://wiki.apache.org/struts/StrutsFileDownload
Are you using struts 1.X or 2.X????
2008/12/15 Dave Newton <ne...@yahoo.com>
> --- On Mon, 12/15/08, elyes sallem wrote:
> > do you have an other solution? the html:file doesn't
> > work for saving a new file
>
> Stream the result (a servlet example was given, it's the same for an
> action-you just return null instead of an ActionForward). The *BROWSER*
> opens a "save as" dialog box.
>
> <html:file...> is a form tag. For sending form data. It doesn't have
> anything to do with downloading files.
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Fwd: export file data using formFile
Posted by Dave Newton <ne...@yahoo.com>.
--- On Mon, 12/15/08, elyes sallem wrote:
> do you have an other solution? the html:file doesn't
> work for saving a new file
Stream the result (a servlet example was given, it's the same for an action-you just return null instead of an ActionForward). The *BROWSER* opens a "save as" dialog box.
<html:file...> is a form tag. For sending form data. It doesn't have anything to do with downloading files.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Fwd: export file data using formFile
Posted by elyes sallem <el...@gmail.com>.
2008/12/15 Dave Newton <ne...@yahoo.com>
> *boggled*
>
> --- On Mon, 12/15/08, elyes sallem <el...@gmail.com> wrote:
> > i used a filechooser class (swing), if any one have an
> > others solution, i'm interested here is the code :
> >
> > String wd = System.getProperty("user.dir");
> > JFileChooser fc = new JFileChooser(wd);
> > int rc = fc.showDialog(null, "Select Data File");
> > if (rc == JFileChooser.APPROVE_OPTION) {
> > File file = fc.getSelectedFile();
> > filename = file.getAbsolutePath();
> > }
> >
> > the problem is that the dialog appears twice
> > after i select a file, it reapper another time asking me to
> > choose a file any one has an idea, is this due to the fact that i use
> > swing in a web application ...?
>
> Um...
>
> Not sure where to begin, but in general Swing isn't required to download a
> file from a web application.
do you have an other solution? the html:file doesn't work for saving a new
file
Regards
Elyes
>
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Elyes.
Re: Fwd: export file data using formFile
Posted by Dave Newton <ne...@yahoo.com>.
*boggled*
--- On Mon, 12/15/08, elyes sallem <el...@gmail.com> wrote:
> i used a filechooser class (swing), if any one have an
> others solution, i'm interested here is the code :
>
> String wd = System.getProperty("user.dir");
> JFileChooser fc = new JFileChooser(wd);
> int rc = fc.showDialog(null, "Select Data File");
> if (rc == JFileChooser.APPROVE_OPTION) {
> File file = fc.getSelectedFile();
> filename = file.getAbsolutePath();
> }
>
> the problem is that the dialog appears twice
> after i select a file, it reapper another time asking me to
> choose a file any one has an idea, is this due to the fact that i use
> swing in a web application ...?
Um...
Not sure where to begin, but in general Swing isn't required to download a file from a web application.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Fwd: export file data using formFile
Posted by elyes sallem <el...@gmail.com>.
i used a filechooser class (swing), if any one have an others solution, i'm
interested
here is the code :
String wd = System.getProperty("user.dir");
JFileChooser fc = new JFileChooser(wd);
int rc = fc.showDialog(null, "Select Data File");
if (rc == JFileChooser.APPROVE_OPTION)
{
File file = fc.getSelectedFile();
filename = file.getAbsolutePath();
// trt
}
the problem is that the dialog appears twice
after i select a file, it reapper another time asking me to choose a file
any one has an idea, is this due to the fact that i use swing in a web
application ...?
Regards
Sallemel
2008/12/15 elyes sallem <el...@gmail.com>
> in fact, i will not do it in a servlet, but in an action (execute method)
>
> Regards
> Elyes
>
>
> 2008/12/15 Robert Graf-Waczenski <rg...@lsoft.com>
>
>> Here's an example:
>>
>>
>> public class Downloader extends HttpServlet
>> {
>> private void doGet(HttpServletRequest req, HttpServletResponse resp)
>> throws IOException
>> {
>> resp.setHeader("Pragma", "no-cache");
>> resp.setHeader("Cache-control", "no-cache");
>> resp.setIntHeader("Expires", -1);
>> MyData data = new MyData();
>> resp.setHeader("content-type", "application/pdf");
>> resp.setHeader("content-encoding", "binary");
>> resp.setHeader("Content-Disposition", "attachment;
>> filename=myfile.pdf");
>> data.writePDFDataToOutputStream(resp.getOutputStream());
>>
>> }
>> }
>>
>>
>> elyes sallem wrote:
>>
>>> ok, do you have an example?
>>>
>>> Thanks
>>> Regards
>>> Elyes
>>>
>>>
>>> 2008/12/15 Dave Newton <ne...@yahoo.com>
>>>
>>>
>>>
>>>> --- On Mon, 12/15/08, elyes sallem wrote:
>>>>
>>>>
>>>>> the problem is that with the html:file you must browse to an
>>>>> existant file, but in my case, i wanna browse to a new file,
>>>>> and then in the action i will make some treatment, generate
>>>>> data and export them to this file
>>>>>
>>>>>
>>>> That's not how you do that.
>>>>
>>>> You stream the response back and the user gets a save-file dialog.
>>>>
>>>> Dave
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
> --
> Elyes.
>
--
Elyes.
Re: Fwd: export file data using formFile
Posted by elyes sallem <el...@gmail.com>.
in fact, i will not do it in a servlet, but in an action (execute method)
Regards
Elyes
2008/12/15 Robert Graf-Waczenski <rg...@lsoft.com>
> Here's an example:
>
> public class Downloader extends HttpServlet
> {
> private void doGet(HttpServletRequest req, HttpServletResponse resp) throws
> IOException
> {
> resp.setHeader("Pragma", "no-cache");
> resp.setHeader("Cache-control", "no-cache");
> resp.setIntHeader("Expires", -1);
> MyData data = new MyData();
> resp.setHeader("content-type", "application/pdf");
> resp.setHeader("content-encoding", "binary");
> resp.setHeader("Content-Disposition", "attachment;
> filename=myfile.pdf");
> data.writePDFDataToOutputStream(resp.getOutputStream());
>
> }
> }
>
>
> elyes sallem wrote:
>
>> ok, do you have an example?
>>
>> Thanks
>> Regards
>> Elyes
>>
>>
>> 2008/12/15 Dave Newton <ne...@yahoo.com>
>>
>>
>>
>>> --- On Mon, 12/15/08, elyes sallem wrote:
>>>
>>>
>>>> the problem is that with the html:file you must browse to an
>>>> existant file, but in my case, i wanna browse to a new file,
>>>> and then in the action i will make some treatment, generate
>>>> data and export them to this file
>>>>
>>>>
>>> That's not how you do that.
>>>
>>> You stream the response back and the user gets a save-file dialog.
>>>
>>> Dave
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>
--
Elyes.
[OT] Re: Fwd: export file data using formFile
Posted by Dave Newton <ne...@yahoo.com>.
--- On Wed, 12/17/08, elyes sallem wrote:
> String mimetype = context.getMimeType(filePath.replaceAll("/", "//"));
You shouldn't need to do that.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Fwd: export file data using formFile
Posted by elyes sallem <el...@gmail.com>.
be coool ...,
in fact i didn't that before download or upload
it is new dev , that is why ...(all we begin by this step, it was the case
for you i suppose...),
furtheremore, i resolved it => (so don't think that i'm waiting response
...)
those who are interested , here is the code i added at the begin :
String mimetype = context.getMimeType(filePath
.replaceAll("/", "//"));
response.setContentType((mimetype != null) ? mimetype
: "application/octet-stream");
response.setContentLength((int) file.length());
response.setHeader("Content-Disposition", "attachment;
filename=\""
+ filePath.replaceAll("/", "//") + "\"");
Regards
Elyes
2008/12/17 Robert Graf-Waczenski <rg...@lsoft.com>
> elyes sallem wrote:
>
>> it forwarded me to page with "unreadable data"
>> comapred to the first example, you omit the
>> resp.setHeader("Content-Disposition", ...
>>
>>
>
> Sorry if this sounds a bit harsh, but the people on this list are not here
> to solve any single Java or Servlet-API related mystery for you. Of course i
> did not supply a fully functional implementation of a doGet() method that
> would give you what you want. In one message i gave you a rough sketch of
> how a typical doGet() method for a download link would look like. Since this
> was not enough and you needed help in how to copy the data from a file on
> your server's disk into the response output stream, i gave you an example
> how to accomplish this. Now you have trouble combining the two parts into a
> working solution. I don't think that we can help you any further on such a
> low level, you'll have to try to figure it out yourself and learn from it.
>
> Robert
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Elyes.
Re: Fwd: export file data using formFile
Posted by Robert Graf-Waczenski <rg...@lsoft.com>.
elyes sallem wrote:
> it forwarded me to page with "unreadable data"
> comapred to the first example, you omit the
> resp.setHeader("Content-Disposition", ...
>
Sorry if this sounds a bit harsh, but the people on this list are not
here to solve any single Java or Servlet-API related mystery for you. Of
course i did not supply a fully functional implementation of a doGet()
method that would give you what you want. In one message i gave you a
rough sketch of how a typical doGet() method for a download link would
look like. Since this was not enough and you needed help in how to copy
the data from a file on your server's disk into the response output
stream, i gave you an example how to accomplish this. Now you have
trouble combining the two parts into a working solution. I don't think
that we can help you any further on such a low level, you'll have to try
to figure it out yourself and learn from it.
Robert
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Fwd: export file data using formFile
Posted by elyes sallem <el...@gmail.com>.
it forwarded me to page with "unreadable data"
comapred to the first example, you omit the
resp.setHeader("Content-Disposition", ...
here is the code ,i have the export method in a dispatch action :
public ActionForward exportSelectedIntaff(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
and i put this, after the creation of the excel file
try {
OutputStream out = response.getOutputStream();
FileInputStream fileStream = new
FileInputStream(filePath.replaceAll("/", "//"));
int bufferLen = 1024 * 8; // 8 KB
byte[] buffer = new byte[bufferLen];
while (true) {
int max = buffer.length;
int len = fileStream.read(buffer, 0, max);
if (len > 0)
out.write(buffer, 0, len);
else
break;
}
} catch (IOException e) {
// TODO: handle exception
}
Regards
Elyes
2008/12/16 Robert Graf-Waczenski <rg...@lsoft.com>
> Hi Elyes,
>
> something like this here should work:
>
> OutputStream out = resp.getOutputStream();
> FileInputStream fileStream = new
> FileInputStream("path/to/your/excelFile.xls");
> int bufferLen = 1024 * 8; // 8 KB
> byte[] buffer = new byte[bufferLen];
> while (true) {
> int max = buffer.length;
> int len = fileStream.read(buffer, 0, max);
> if (len > 0)
> out.write(buffer, 0, len);
> else
> break;
> }
>
> Bye,
>
> Robert
>
>
>
> elyes sallem wrote:
>
>> Hello Robert ,
>> so assume that i have an excel file on the server
>> and i have a button to download it for the client (of course with a browse
>> dialog)
>> could you show me how develop it , in your example , you call
>> writePDFDataToOutputStream
>> and it is a pdf file which is not my case
>>
>> Thanks
>> Regards
>> Elyes
>>
>>
>>
>>
>>
>> 2008/12/15 Robert Graf-Waczenski <rg...@lsoft.com>
>>
>>
>>
>>> Here's an example:
>>>
>>> public class Downloader extends HttpServlet
>>> {
>>> private void doGet(HttpServletRequest req, HttpServletResponse resp)
>>> throws
>>> IOException
>>> {
>>> resp.setHeader("Pragma", "no-cache");
>>> resp.setHeader("Cache-control", "no-cache");
>>> resp.setIntHeader("Expires", -1);
>>> MyData data = new MyData();
>>> resp.setHeader("content-type", "application/pdf");
>>> resp.setHeader("content-encoding", "binary");
>>> resp.setHeader("Content-Disposition", "attachment;
>>> filename=myfile.pdf");
>>> data.writePDFDataToOutputStream(resp.getOutputStream());
>>>
>>> }
>>> }
>>>
>>>
>>> elyes sallem wrote:
>>>
>>>
>>>
>>>> ok, do you have an example?
>>>>
>>>> Thanks
>>>> Regards
>>>> Elyes
>>>>
>>>>
>>>> 2008/12/15 Dave Newton <ne...@yahoo.com>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> --- On Mon, 12/15/08, elyes sallem wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> the problem is that with the html:file you must browse to an
>>>>>> existant file, but in my case, i wanna browse to a new file,
>>>>>> and then in the action i will make some treatment, generate
>>>>>> data and export them to this file
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> That's not how you do that.
>>>>>
>>>>> You stream the response back and the user gets a save-file dialog.
>>>>>
>>>>> Dave
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>>
>
>
--
Elyes.
Re: Fwd: export file data using formFile
Posted by Robert Graf-Waczenski <rg...@lsoft.com>.
Hi Elyes,
something like this here should work:
OutputStream out = resp.getOutputStream();
FileInputStream fileStream = new
FileInputStream("path/to/your/excelFile.xls");
int bufferLen = 1024 * 8; // 8 KB
byte[] buffer = new byte[bufferLen];
while (true) {
int max = buffer.length;
int len = fileStream.read(buffer, 0, max);
if (len > 0)
out.write(buffer, 0, len);
else
break;
}
Bye,
Robert
elyes sallem wrote:
> Hello Robert ,
> so assume that i have an excel file on the server
> and i have a button to download it for the client (of course with a browse
> dialog)
> could you show me how develop it , in your example , you call
> writePDFDataToOutputStream
> and it is a pdf file which is not my case
>
> Thanks
> Regards
> Elyes
>
>
>
>
>
> 2008/12/15 Robert Graf-Waczenski <rg...@lsoft.com>
>
>
>> Here's an example:
>>
>> public class Downloader extends HttpServlet
>> {
>> private void doGet(HttpServletRequest req, HttpServletResponse resp) throws
>> IOException
>> {
>> resp.setHeader("Pragma", "no-cache");
>> resp.setHeader("Cache-control", "no-cache");
>> resp.setIntHeader("Expires", -1);
>> MyData data = new MyData();
>> resp.setHeader("content-type", "application/pdf");
>> resp.setHeader("content-encoding", "binary");
>> resp.setHeader("Content-Disposition", "attachment;
>> filename=myfile.pdf");
>> data.writePDFDataToOutputStream(resp.getOutputStream());
>>
>> }
>> }
>>
>>
>> elyes sallem wrote:
>>
>>
>>> ok, do you have an example?
>>>
>>> Thanks
>>> Regards
>>> Elyes
>>>
>>>
>>> 2008/12/15 Dave Newton <ne...@yahoo.com>
>>>
>>>
>>>
>>>
>>>> --- On Mon, 12/15/08, elyes sallem wrote:
>>>>
>>>>
>>>>
>>>>> the problem is that with the html:file you must browse to an
>>>>> existant file, but in my case, i wanna browse to a new file,
>>>>> and then in the action i will make some treatment, generate
>>>>> data and export them to this file
>>>>>
>>>>>
>>>>>
>>>> That's not how you do that.
>>>>
>>>> You stream the response back and the user gets a save-file dialog.
>>>>
>>>> Dave
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>
>
>
Re: Fwd: export file data using formFile
Posted by elyes sallem <el...@gmail.com>.
Hello Robert ,
so assume that i have an excel file on the server
and i have a button to download it for the client (of course with a browse
dialog)
could you show me how develop it , in your example , you call
writePDFDataToOutputStream
and it is a pdf file which is not my case
Thanks
Regards
Elyes
2008/12/15 Robert Graf-Waczenski <rg...@lsoft.com>
> Here's an example:
>
> public class Downloader extends HttpServlet
> {
> private void doGet(HttpServletRequest req, HttpServletResponse resp) throws
> IOException
> {
> resp.setHeader("Pragma", "no-cache");
> resp.setHeader("Cache-control", "no-cache");
> resp.setIntHeader("Expires", -1);
> MyData data = new MyData();
> resp.setHeader("content-type", "application/pdf");
> resp.setHeader("content-encoding", "binary");
> resp.setHeader("Content-Disposition", "attachment;
> filename=myfile.pdf");
> data.writePDFDataToOutputStream(resp.getOutputStream());
>
> }
> }
>
>
> elyes sallem wrote:
>
>> ok, do you have an example?
>>
>> Thanks
>> Regards
>> Elyes
>>
>>
>> 2008/12/15 Dave Newton <ne...@yahoo.com>
>>
>>
>>
>>> --- On Mon, 12/15/08, elyes sallem wrote:
>>>
>>>
>>>> the problem is that with the html:file you must browse to an
>>>> existant file, but in my case, i wanna browse to a new file,
>>>> and then in the action i will make some treatment, generate
>>>> data and export them to this file
>>>>
>>>>
>>> That's not how you do that.
>>>
>>> You stream the response back and the user gets a save-file dialog.
>>>
>>> Dave
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>
--
Elyes.
Re: Fwd: export file data using formFile
Posted by Robert Graf-Waczenski <rg...@lsoft.com>.
Here's an example:
public class Downloader extends HttpServlet
{
private void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException
{
resp.setHeader("Pragma", "no-cache");
resp.setHeader("Cache-control", "no-cache");
resp.setIntHeader("Expires", -1);
MyData data = new MyData();
resp.setHeader("content-type", "application/pdf");
resp.setHeader("content-encoding", "binary");
resp.setHeader("Content-Disposition", "attachment;
filename=myfile.pdf");
data.writePDFDataToOutputStream(resp.getOutputStream());
}
}
elyes sallem wrote:
> ok, do you have an example?
>
> Thanks
> Regards
> Elyes
>
>
> 2008/12/15 Dave Newton <ne...@yahoo.com>
>
>
>> --- On Mon, 12/15/08, elyes sallem wrote:
>>
>>> the problem is that with the html:file you must browse to an
>>> existant file, but in my case, i wanna browse to a new file,
>>> and then in the action i will make some treatment, generate
>>> data and export them to this file
>>>
>> That's not how you do that.
>>
>> You stream the response back and the user gets a save-file dialog.
>>
>> Dave
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
>
Re: Fwd: export file data using formFile
Posted by elyes sallem <el...@gmail.com>.
ok, do you have an example?
Thanks
Regards
Elyes
2008/12/15 Dave Newton <ne...@yahoo.com>
> --- On Mon, 12/15/08, elyes sallem wrote:
> > the problem is that with the html:file you must browse to an
> > existant file, but in my case, i wanna browse to a new file,
> > and then in the action i will make some treatment, generate
> > data and export them to this file
>
> That's not how you do that.
>
> You stream the response back and the user gets a save-file dialog.
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Elyes.
Re: Fwd: export file data using formFile
Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
That's what the "Save As" dialog is for.
Nils-H
On Mon, Dec 15, 2008 at 3:03 PM, elyes sallem <el...@gmail.com> wrote:
> the problem is that with the html:file you must browse to an existant file,
> but in my case, i wanna browse to a new file, and then in the action
> i will make some treatment, generate data and export them to this file
>
>
> 2008/12/15 Dave Newton <ne...@yahoo.com>
>
>> --- On Mon, 12/15/08, elyes sallem wrote:
>> > it is not to export the file content , i want juste get back in the
>> > action, the *selected file path*
>>
>> Oh, I thought you said "[...] struts tag to export file [...]"
>>
>> >> --- On Mon, 12/15/08, elyes sallem wrote:
>> >>> all i want, is what is the struts tag to export file [...]
>>
>> FormFile has a getFileName() method. Different browsers submit different
>> values for this: some send the entire path, some just send the file name.
>>
>> Is that also not what you're asking?
>>
>> Dave
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> --
> Elyes.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Fwd: export file data using formFile
Posted by elyes sallem <el...@gmail.com>.
the data will be generated dynamically , depending on others selected fields
and based on a select to a database table, i will generate a csv file
2008/12/15 Robert Graf-Waczenski <rg...@lsoft.com>
> Hm. Sounds more like a download, not like an upload. Is that what you're
> after?
>
> Robert
>
>
> elyes sallem wrote:
>
>> the problem is that with the html:file you must browse to an existant
>> file,
>> but in my case, i wanna browse to a new file, and then in the action
>> i will make some treatment, generate data and export them to this file
>>
>>
>> 2008/12/15 Dave Newton <ne...@yahoo.com>
>>
>>
>>
>>> --- On Mon, 12/15/08, elyes sallem wrote:
>>>
>>>
>>>> it is not to export the file content , i want juste get back in the
>>>> action, the *selected file path*
>>>>
>>>>
>>> Oh, I thought you said "[...] struts tag to export file [...]"
>>>
>>>
>>>
>>>> --- On Mon, 12/15/08, elyes sallem wrote:
>>>>>
>>>>>
>>>>>> all i want, is what is the struts tag to export file [...]
>>>>>>
>>>>>>
>>>>> FormFile has a getFileName() method. Different browsers submit
>>> different
>>> values for this: some send the entire path, some just send the file name.
>>>
>>> Is that also not what you're asking?
>>>
>>> Dave
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>
--
Elyes.
Re: Fwd: export file data using formFile
Posted by Robert Graf-Waczenski <rg...@lsoft.com>.
Hm. Sounds more like a download, not like an upload. Is that what you're
after?
Robert
elyes sallem wrote:
> the problem is that with the html:file you must browse to an existant file,
> but in my case, i wanna browse to a new file, and then in the action
> i will make some treatment, generate data and export them to this file
>
>
> 2008/12/15 Dave Newton <ne...@yahoo.com>
>
>
>> --- On Mon, 12/15/08, elyes sallem wrote:
>>
>>> it is not to export the file content , i want juste get back in the
>>> action, the *selected file path*
>>>
>> Oh, I thought you said "[...] struts tag to export file [...]"
>>
>>
>>>> --- On Mon, 12/15/08, elyes sallem wrote:
>>>>
>>>>> all i want, is what is the struts tag to export file [...]
>>>>>
>> FormFile has a getFileName() method. Different browsers submit different
>> values for this: some send the entire path, some just send the file name.
>>
>> Is that also not what you're asking?
>>
>> Dave
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
>
Re: Fwd: export file data using formFile
Posted by Dave Newton <ne...@yahoo.com>.
--- On Mon, 12/15/08, elyes sallem wrote:
> the problem is that with the html:file you must browse to an
> existant file, but in my case, i wanna browse to a new file,
> and then in the action i will make some treatment, generate
> data and export them to this file
That's not how you do that.
You stream the response back and the user gets a save-file dialog.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Fwd: export file data using formFile
Posted by elyes sallem <el...@gmail.com>.
the problem is that with the html:file you must browse to an existant file,
but in my case, i wanna browse to a new file, and then in the action
i will make some treatment, generate data and export them to this file
2008/12/15 Dave Newton <ne...@yahoo.com>
> --- On Mon, 12/15/08, elyes sallem wrote:
> > it is not to export the file content , i want juste get back in the
> > action, the *selected file path*
>
> Oh, I thought you said "[...] struts tag to export file [...]"
>
> >> --- On Mon, 12/15/08, elyes sallem wrote:
> >>> all i want, is what is the struts tag to export file [...]
>
> FormFile has a getFileName() method. Different browsers submit different
> values for this: some send the entire path, some just send the file name.
>
> Is that also not what you're asking?
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Elyes.
Re: Fwd: export file data using formFile
Posted by Robert Graf-Waczenski <rg...@lsoft.com>.
There is no reliable way to get the selected file path. This has been
discussed a few days ago on this list.
Robert
elyes sallem wrote:
> it is not to export the file content
> , i want juste get back in the action, the *selected file path*
>
> 2008/12/15 Dave Newton <ne...@yahoo.com>
>
>
>> --- On Mon, 12/15/08, elyes sallem wrote:
>>
>>> all i want, is what is the struts tag to export file [...]
>>>
>> There is no tag to export a file.
>>
>> Dave
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
>
Re: Fwd: export file data using formFile
Posted by Dave Newton <ne...@yahoo.com>.
--- On Mon, 12/15/08, elyes sallem wrote:
> it is not to export the file content , i want juste get back in the
> action, the *selected file path*
Oh, I thought you said "[...] struts tag to export file [...]"
>> --- On Mon, 12/15/08, elyes sallem wrote:
>>> all i want, is what is the struts tag to export file [...]
FormFile has a getFileName() method. Different browsers submit different values for this: some send the entire path, some just send the file name.
Is that also not what you're asking?
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Fwd: export file data using formFile
Posted by elyes sallem <el...@gmail.com>.
it is not to export the file content
, i want juste get back in the action, the *selected file path*
2008/12/15 Dave Newton <ne...@yahoo.com>
> --- On Mon, 12/15/08, elyes sallem wrote:
> > all i want, is what is the struts tag to export file [...]
>
> There is no tag to export a file.
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Elyes.
Re: Fwd: export file data using formFile
Posted by Dave Newton <ne...@yahoo.com>.
--- On Mon, 12/15/08, elyes sallem wrote:
> all i want, is what is the struts tag to export file [...]
There is no tag to export a file.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Fwd: export file data using formFile
Posted by elyes sallem <el...@gmail.com>.
all i want, is what is the struts tag to export file
with html:file, if i browse to unexistant file, (which is the case for me,
because i will export data in this new file)
i get a warning "file doesn't exist"
so what is the struts tag i must use to export a new file
Regards
Elyes
---------- Forwarded message ----------
From: elyes sallem <el...@gmail.com>
Date: 2008/12/15
Subject: export file data using formFile
To: Struts Users Mailing List <us...@struts.apache.org>
Hello,
i want to use a formfile in jsp page, where once i browse to file , i want
to laucnh directly the action, export data to this file
(without a submit button near the fromfile)
how can i make it?
Regards
Elyes.
--
Elyes.