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 <elyes.sal...@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 <r...@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 <newton.d...@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-unsubscr...@struts.apache.org
>>>> For additional commands, e-mail: user-h...@struts.apache.org
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
> --
> Elyes.
>



-- 
Elyes.

Reply via email to