This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Servlets
Author
how to save the file in clint side in temp folder
Shyam Hai
Ranch Hand
Joined: Feb 04, 2009
Posts: 68
posted
Mar 10, 2010 00:13:46
0
hi,
I want do download the file from server and save in client side in temp folder.
I want to store the file without knowing the user.
Now i am using this code.
String filename = "C:\\Test\\TestFile.txt"; response.setContentType("application/octet-stream"); String disHeader = "Attachment; Filename=\"filename\""; response.setHeader("Content-Disposition", disHeader); File fileToDownload = new File(filename); InputStream in = null; ServletOutputStream outs = response.getOutputStream(); try { in = new BufferedInputStream (new FileInputStream(fileToDownload)); int ch; while ((ch = in.read()) != -1) { outs.print((char) ch); System.out.print((char) ch); } } finally { if (in != null) in.close(); // very important } outs.flush(); outs.close(); in.close();
When i use this code in
servlet
.
its working fine but its ask location for store the file.
But i want to save the file in Temp foler without knowing user.
please help me.
how can i do.
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
I like...
posted
Mar 10, 2010 05:25:05
0
You can't.
And it's a good thing, because if somebody's web site started writing files all over my disk without me knowing I'd be pretty angry.
You might be able to do something with an
applet
.
I agree. Here's the link:
http://zeroturnaround.com/jrebel/download
subject: how to save the file in clint side in temp folder
Similar Threads
How to download a file from the server to the client machine?
opening an excel file through Java
open a .exe in java (DLL Problem)
Download a file from Server to client machine
Handling menu events
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter