File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Download data on to local machine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Download data on to local machine" Watch "Download data on to local machine" New topic

Download data on to local machine

dileep keely
Ranch Hand

Joined: Jun 28, 2010
Posts: 108
1)I have created a jsp(index.jsp) and a Servlet that gives the output after processing the error.log files using FileOutputStream based on the given input(say, name) to the index.jsp
2)I have a button "SaveClipboardData" created on jsp that allows to copy the data onclick of that.

The problem is when I deploy that application in the remote server obviously the data get copied on to the remote machine,because
I gave the file path as below in the servlet .

Instead what I was looking at is if any client click the "SaveClipboardData" button on "index.jsp" there should be a prompt
which allows him to browse to his local directory and copy the data into his(Client) localmachine rather then on the remote.(Similar to the webpages that
we download)

Please suggest me how to proceed
Tom Reilly

Joined: Jun 01, 2010
Posts: 618
You need to send the data back to the browser - not save the data to a file. Investigate Response.getWriter() and Response.SetContentType(). Note that you cannot force a browser to prompt a user to select a file to save to disk. That all depends on how the user sets up the browser.
I agree. Here's the link:
subject: Download data on to local machine
jQuery in Action, 3rd edition