Save file on client

hi!
there must be a solution to this problem! can anybody tell?
i want du save text in a file on the client, how to do?
thanks a lot!

i've got an error!
Cannot forward after response has been committed!
    try {
                    downloadFile (((HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse()),new File(path));
                    getFacesContext().getCurrentInstance().responseComplete();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }and the download-method:
    public static void downloadFile(
        HttpServletResponse response, File file)
            throws IOException
        BufferedInputStream input = null;
        BufferedOutputStream output = null;
        try {
            // Wrap the file in a BufferedInputStream and pass it through another method.
            input = new BufferedInputStream(new FileInputStream(file));
         //   downloadFile(response, input, file.getName(), attachment);
            int contentLength = input.available();
            String contentType = URLConnection.guessContentTypeFromName(file.getName());
            response.setContentLength(contentLength);
            response.setContentType(contentType);
            response.setHeader(
                "Content-disposition", "attachment" + "; filename=\"" + file.getName() + "\"");
            output = new BufferedOutputStream(response.getOutputStream());
            // Write file contents to response.
            while (contentLength-- > 0) {
                output.write(input.read());
            output.flush();
        } catch (IOException e) {
            throw e;
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    e.printStackTrace();
             if (output != null) {
                try {
                    output.close();
                } catch (IOException e) {
                    e.printStackTrace();
    }

Similar Messages

  • Save file on client machine on the web.....

    Hi,
    I have a Form Application C/S 6i where I create a file using Get_File_Name, TEXT_IO.fopen .... etc. This application it's OK. The problem is when I load the application on AIS9i. The application don't load never. I must create and save a file on client machine when I use application on the web. What Can I do? Is This operation possible without radical change of the code source?
    Thanks

    Erik,
    actually this project is under the leadership of the same author that created d2kwutil. It is too early to tell what exactly will be in this package and most likely we will release things step by step as they finish. However, you canuse this thread for a wishlist of functionality and I will pass it to the project lead. The implementation will be both POL/SQL and Java (as Java is the only way for us to access the client side in teh Web). The project target is sometime mid of next year. As said, the project hasn't really started yet so it is too early to speculate on what will make it in and when this will be delivered.
    Frank

  • Path does not exit - While trying to save file on SharPoint Server 2013 from client machine

    Hi,
    I have installed Microsoft SharePoint Server 2013 Enterprise Edition on my testing Lab environment (On VM Workstation 10) on Windows Server 2012 with SQL server 2012, I can access all files stored at SharePoint Server from any physical machine, I can share
    a single file among different people to work simultaneously, but here i stuck on saving any file from client machine to directly on SharePoint Server, Attached is the snap shot, whenever I try to save any file directly It says Path Does Not Exist, If I drag
    and drop any file directly to SharePoint I do not see any error message.
    I read from different posts that I need to Enable Desktop Experience Feature on Server 2012, which I installed but no positive result gained :(
    I will appreciate for any possible help?
    Ali

    Hi Ali,
    Please try disabling the protected view per the link below and test the issue again:
    http://social.technet.microsoft.com/Forums/en-US/b8381a19-3394-406f-8adb-1976f45460ef/path-does-not-exit-while-trying-to-save-file-on-sharpoint-server-2013-from-client-machine?forum=sharepointgeneral
    You could simply type the url as http://sp/sites/sitename in the Filename place.
    Regards,
    Rebecca Tu
    TechNet Community Support

  • What is the best strategy to save a file in client computer

    I want to save some information in a file in client computer. What is the best strategy to do? There are some ways I can think about. But none of them is good enough for me.
    1. I gave all-permission. So, I can actually write what I want. But, in order to make the program runs on all platform/all client computers, I can't make any assumptions on file system of client computer. So, this is not good.
    2. I can write a file into .javaws directory. But, how can I get file path for this directory? JNLP API does not give this path to us. I can't think a way to get this path for all client computer (WIndown, Mac, Unix).
    3. To write as a muffin. Seems fine. But, I often change server and path. So, once I changed server, the client will loss the file saved since muffin is associated with server and path.
    4. I can just open one file with on path. I think J2SE will treat this file platform dependently. For example, for W2K this file will be put into Desktop. This is bad.
    Any better idea?

    In the past I have used the Properties class to do things like this. Using load and store, you can read and write key=value pairs.
    I store the file in the user.home directory. You can use System.getProperty("user.home") to get this location.
    No guarantees, but I thought that this user.home property was good for any OS with a home directory concept. If that turns out not to be true, maybe the System property java.io.tmpdir would be more consistent across platforms. This, of course, would be subject to delete by the OS/administrators.
    -Dave

  • To upload a file from client machine to server machine

    Hi everybody!
    Could anyone plz help me. I am struck in a problem
    I want to transfer a file from client's machine to server but I am not able to upload
    It is tranferring the file only to the local machine
    I am using orielley package It is transferring files only to my local machine but not to the server .Can anyone correct it. It's very urgent
    how to write the relative path for server
    I am using this path and it is not uploading
    MultipartRequest multi = new MultipartRequest(request, "../<administrator>:<dev2daask>@dev2:C:/123data/", 5 * 1024 * 1024);
    Here is my code:
    <%@ page import="java.util.*" %>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.servlet.http.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="com.oreilly.servlet.MultipartRequest"%>
    <%
    try {
    // Blindly take it on faith this is a multipart/form-data request
    // Construct a MultipartRequest to help read the information.
    // Pass in the request, a directory to saves files to, and the
    // maximum POST size we should attempt to handle.
    // Here we (rudely) write to the server root and impose 5 Meg limit.
    MultipartRequest multi = new MultipartRequest(request, "../<administrator>:<dev2daask>@dev2:C:/123data/", 5 * 1024 * 1024);
    out.println("<HTML>");
    out.println("<HEAD><TITLE>UploadTest</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("<H1>UploadTest</H1>");
    // Print the parameters we received
    out.println("<H3>Params:</H3>");
    out.println("<PRE>");
    Enumeration params = multi.getParameterNames();
    while (params.hasMoreElements()) {
    String name = (String)params.nextElement();
    String value = multi.getParameter(name);
    out.println(name + " = " + value);
    out.println("</PRE>");
    // Show which files we received
    out.println("<H3>Files:</H3>");
    out.println("<PRE>");
    Enumeration files = multi.getFileNames();
    while (files.hasMoreElements()) {
    String name = (String)files.nextElement();
    String filename = multi.getFilesystemName(name);
    String type = multi.getContentType(name);
    File f = multi.getFile(name);
    out.println("name: " + name);
    out.println("filename: " + filename);
    out.println("type: " + type);
    if (f != null) {
    out.println("length: " + f.length());
    out.println();
    out.println("</PRE>");
    catch (Exception e) {
    out.println("<PRE>");
    out.println("</PRE>");
    out.println("</BODY></HTML>");
    %>

    you have not understood my point
    how does this code will run on servlet when I want to upload a file from client's
    machine to server machine
    what I am doing is I am giving an option to the user that he/she can browse the file and then select any file and finally it's action is post in the jsp form for which I have sent the code
    All the computers are connected in LAN
    So how to upload a file from client's machine to server's machine
    Plz give me a solution

  • How to open and save file like the Notepad Demo do?

    I am a newer to Java Web Start. I found that in the Notepad Demo, when user try to open or save file, a message box appear and give the user some security suggestions.
    In my application, I used a JFileChooser and set the <security> element to <j2ee-application-client-permissions/> in the jnlp file. But the application will thow an exception:
    access denied (java.io.FilePermission C:\Documents and Settings\Administrator\desktop\Java Web Start.lnk read)
    Can someone tell me how to solve this problem. By the way, where can I find the source of the Notepad Demo. I want my application to open and save file just like the Notepad Demo do.

    The Notpad demo uses the JNLP api to read and write files. The api doc can be found at:
    http://java.sun.com/products/javawebstart/docs/javadoc/index.html
    Although the Notpad demo source is not available, there is other sample code available at:
    http://developer.java.sun.com/developer/releases/javawebstart/
    Included here is the webpad demo, which uses the FileOpenService and
    FileSaveService API's.

  • Photoshop cs 5.5 on mac os 10.6.8 error in save file

    Photoshop and illustrator CS 5.5 problem to save file in network SMB server
    The client is Mac OS X 10.6.8 Snow Leopard
    Any idea?

    Photoshop and illustrator CS 5.5 problem to save file in network SMB server
    The client is Mac OS X 10.6.8 Snow Leopard
    Any idea?

  • Applet-Servlet - Creating a new file on client's mashine

    Hi all!
    I need to write a program, that will get a data from client through Applet text fields and save it to a new(or rewrite existing) file on client mashine. To save it, I want to use Servlet, because Applet can't do this because of security restrictions. So I think of sending data from Applet to Servlet, which will save it in a new file (will download this file back to the client's mashine).
    I found the following code in forums to download a file from server to client:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class OutputFileOnBrowser extends HttpServlet {
    public void service(HttpServletRequest req,HttpServletResponse res)
    throws ServletException, IOException
    res.setContentType("application/x-filler");
    res.setHeader("Content-Disposition", "attachment; filename=out.fif;");
    ServletOutputStream stream = res.getOutputStream();
    BufferedInputStream fif = new BufferedInputStream(new FileInputStream("in.fif"));
    int data;
    while((data = fif.read()) != -1)
    stream.write(data);
    fif.close();
    stream.close();
    but I don't understand, does it automatically downloads the file out.fif to client's disc and in what path? I tried it, and it did nothing. Anyway, this code doesn't fit exactly my purpose, because I have first to create the file.
    Could anybody help me please?
    Thank you in advanse!
    P.S. I've already wrote the Applet code, what I need now is o n l y the help with a Servlet part!
    Best regards.

    Thanks, but I want not client but servlet save the file automatically in a given path on client's mashine. Is there any way to do that?
    Thanks.

  • How to put image file on client machine through JBOSS

    I need to imlement the functionality like google map on website, where my server is JBOSS
    server. We used the newest technology SVG(scalable vector graphics) which doesn't loose the
    image quaility on increasing the size of the image.
    we are doing backend processing of the image and throwing the png images on the client.
    machine. I already written a program which can be used at the time of zooming and panning
    of the image and can throw the image but that is all PC based. but when I am implementing
    on the server it is giving error because code is not getting any output directory to save
    the image on sever.
    Please tell me if that can be happen through caching or how can I save image on
    client machine without user authenication and can retrieve on the web page. so that my
    server doesn't have extra load.

    hi jagdish,
    Check this thread. discussed uploading file step by step
    Re: How to upload and search a document in KM
    Regards,
    Ganesh N

  • SharePoint Library - If I save file from Excel File Save As - then I always get "File already exists. Do you want to replace it?" - Upload works fine though.

    Hi there,
    In my SP 2010 document library - When I try to save an Excel file from File > Save As menu to the document library it always prompts me "File already exists. Do you want to replace it?" even though the file does not exist in that document library.
    To the same document library - if I upload a file then it accepts it all fine.
    Any clues why I cannot save files using File > Save As menu?
    Thanks.

    Hi,
    As I understand, the notification pops up when you save an excel file to SharePoint library, while when directly upload file to library, there is no wrong.
    Please confirm if the issue occurs to other machines.
    Please open Microsoft Office Upload Center on the issue machine, then click settings, clear cache via checking Delete files from the Office Document Cache when they are closed.
    http://office.microsoft.com/en-in/excel-help/office-document-cache-settings-HA010388664.aspx
    If the issue occurs to client, I’d recommend you also ask the question in Excel forum:
    http://social.technet.microsoft.com/Forums/office/en-US/home?forum=excel
    Regards,
    Rebecca Tu
    TechNet Community Support

  • Save file to database using WEBUTIL

    Hi,
    I have used webutil_file_transfer.Client_To_AS_with_progress to upload files from client to Application Server using Forms 10g
    However, now i want to save file in database and not upload to database.
    Apart from the problem, I was wondering if there is documentation available on WEBUTIL
    Please help

    I want to store the file in the database as a BLOB.
    Earlier I was uploading to Application Server.
    I had used webutil_file_transfer.Client_To_AS_with_progress to upload to Server,
    I hope there is a procedure / function similar to Client_To_AS_with_progress in the webutil_file_transfer package

  • Open file in client computer

    hi
    how can i open file in client computer when he click on a button
    i want to show him a xls file and if he want save it on his computer
    can i save on his computer too?
    tanx

    ok
    when i said " i said a program in server" mean in
    my previous post i said i want to open file that
    its place in server and want to show userAll you need for that is a webserver. Are you creating that file on the fly?
    can i open file with java prog in user comp?A signed applet can download the file and fire off th rRuntime.exec() command shown earlier. You claimed to be limited in doing that by not knowing their OS. That may be true, but there aren't many OSes that can run Excel to begin with.
    if u know both applet and jsp(not servlet)Once more: JSPs are servlets. Same technology, different appearance. And as far as the user's concerned, it's all HTML. Totally irrelevant how it's created. You can have the servlet stream out the file in case it's indeed created on the fliy, using the reply's output stream and the appropriate MIME type setting. If it's static, I say don't bother and simply put it onto the webserver.
    please
    tell me
    or if java dont permision to do this tell it so

  • Cannot save file in word for mac 2011

         When I tried to save a word file, the system keep telling me "this file is being used by another program, please save again" then the file name turned into something like "Word Work File L_230232796.tmp" and I have to choose another name for the file. Besides, sometimes the new file cannot be opened correctly. How can I solve it?

    perhaps ignore a little the standard search microsoft forum response above for the moment, the problem may lie with apple, as I doubt these problems occurred with snow leopard and previous, as its the new OSX file versioning autosaving features that seemed to have cause allot of issues not just with office, my clients cant stand the lack of "save as" for instance, this new autosave features also has a hidden ability to lock files older than a certain age hidden within time machine preferences this might and I say "might" be the issue in question although "blocked" is more unusual in contrast to to the more common "locked" as an error, follow the following points in order >
    1: just check this article to see whether it may help with your issue.
    http://www.maclife.com/article/howtos/how_disable_os_x_lion_file_locking
    2: do the standard updates software routine to both office and osx you can, ie to 10.7.5 for lion for instance.
    3: do the standard disk utility permissions repair, although this sadly only affects, files other than user folders, user folder permission repair can be done but is more complicated.
    4: some with this issue recommend turning off time machine backups completely, as it also seems to interact with this issue, test this ?
    5: check with docs of different files sizes to establis whether its file size related and respond back to the thread
    6: if related to dropbox make sure its fully updated, aagan try saving in a different file location and test respond back to the thread
    7: Note also lion and mountain lion have changed and tightened quite a bit the permissions and user control over OSX and file locations etc, for the endless over perceived security risks out there, meaning for instance lion will no longer let you save files to root without putting in your password etc, so Might I suggest also making sure that where your saving your word documents is within the user folder temporarily ? and see whether that resolves the issue. ie the file saving location in question maybe the issue.
    8: Sadly if you recently did an "upgrade to Lion", some Software issues may also resolved by reinstalling the said software afterwards, negating the point of an upgrade install, but anyway … as that can sometimes resolve issues with software from a Lion Upgrade.
    further :  if this is related to a temporary file save location within the application package as some software makers seem to do ? then permissions repair may have resolved it or it may require a microsoft update to the office suite if so, I thought doc temp files as regards microsoft documents were saved alongside the original file ? could be a temp elsewhere though perhaps in the Microsoft folder in the user>library>application support maybe the issue stems from permissions there ? a search can reveal how to repair the permissions on the user folder which cannot be done through disk utility as standard, though i doubt this will resolve it. OS X lion and up and the new autosave feature, versioning and file locking time machine backups and the lack of "save as in some application have created allot of issues for allot of people you are not alone in these issues.

  • Not able to Check-out/Check-in .pdf file from Client application in SharePoint 2013

    Hi,
    When I click on .pdf document in document library its getting opened in browser not client application.
    I have done all the below settings.
    1. Set Opening Documents in the Browser as Open in Client Application.
    2. Activated Open Documents in Client Application by Default.
    Still .pdf files getting opened in browser.
    Then I Tried by doing the below Internet Setting.
           In Internet Explorer -> Manage add-ons and disabled Adobe PDF Reader -> Disable (So that the pdf should open in Browser).
    Now I am able to Open the document in Client application but its not connected to SharePoint (
    I am not able to do Check-in/Check-out/Save file back to SharePoint).
    Can Any one Help me with this issue.
    Also note Build number and CU :
    15.0.4675.1000 - December 2014
    Thanks in advance.
    pavan2920

    the option to open a PDF in the browser is based on the Web Application's list of allowed MIME types... it cannot be controlled on a per-library basis.
    see: http://social.technet.microsoft.com/wiki/contents/articles/8073.sharepoint-browser-file-handling-deep-dive.aspx
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

  • Suggest a filename extension in a save file dialog

    Hello guys,
    does any of you know, how to suggest the user a certain filename extension in a save file dialog?
    I'm using both the normal save file dialog:
         javax.swing.JFileChooser.showSaveDialog,
    and the Java Web Start save file dialog:
         javax.jnlp.FileSaveService.saveFileDialog.
    For both ways I seem not to be able to suggest the user a certain extension for the filename.
    For the normal dialog, I call setFileFilter on the JFileChooser instance.
    The filter shows up in the dialog, and is used by default, but when the user types a name and approves, the returned filename does not have the extension added.
    Of course I can add the extension programmaticaly, but not when inside the JAWS sandbox.
    For the JAWS dialog, I pass an array containing my extension, but it is ignored as if I didn't specify any extensions. The API specs already say that this parameter "might be ignored by the JNLP Client".
    So how to tell the user what extension to use?
    More people must have encountered this problem.
    I'm making an application that saves and opens xml files and exports html files.
    I'm using this code to test the behavior:import java.io.ByteArrayInputStream;
    import java.io.File;
    import javax.jnlp.FileContents;
    import javax.jnlp.FileSaveService;
    import javax.jnlp.ServiceManager;
    import javax.jnlp.UnavailableServiceException;
    import javax.swing.JFileChooser;
    import javax.swing.filechooser.FileFilter;
    public class ChooseFile
        static final String[] EXTENSIONS = { "xml" };
        static final String DESCRIPTION = "XML files";
        public static void main(String[] args)
         try {
             ServiceManager.lookup("javax.jnlp.FileOpenService");
             // we're running with JAWS
             System.out.println("JAWS filechooser:");
             System.out.println(choose_JAWS());
         catch (UnavailableServiceException x)
             // we're NOT running with JAWS
             System.out.println("normal filechooser:");
             System.out.println(choose_normal());
        static String choose_normal()
         JFileChooser fc = new JFileChooser();
         fc.setFileFilter(new CustomFileFilter(EXTENSIONS, DESCRIPTION));
         if (JFileChooser.APPROVE_OPTION == fc.showSaveDialog(null))
             return "selected " + fc.getSelectedFile().getName();
         else
             return "cancelled";
        static String choose_JAWS()
         try {
             FileSaveService fos = (FileSaveService)ServiceManager.lookup(
                         "javax.jnlp.FileSaveService");
             ByteArrayInputStream stream = new ByteArrayInputStream(new byte[] {});
             FileContents fc = fos.saveFileDialog(null, EXTENSIONS, stream, null);
             if (fc != null)
              return "selected " + fc.getName();
             else
              return "cancelled";
         } catch (Exception x)
             x.printStackTrace();
            return "";
    class CustomFileFilter extends FileFilter
        String[] extensions;
        String description;
        public CustomFileFilter(String[] extensions, String description)
         this.extensions = extensions;
         this.description = description;
        public boolean accept(File f)
         if (f.isDirectory())
             return true;
         String extension = getExtension(f);
            if (extension == null)
                return false;
         for (int i=extensions.length; i-->0; )
             if (extension.equals(extensions))
              return true;
         return false;
    public String getDescription()
         return description;
    private String getExtension(File f)
    String ext = null;
    String s = f.getName();
    int i = s.lastIndexOf('.');
    if (i > 0 && i < s.length() - 1)
    ext = s.substring(i+1).toLowerCase();
    return ext;
    }Any help is greatly appreciated!
    Tom Jansen

    @tjacobs01
    Hi Tom,
    I have a question regarding your classes
    tjacobs.ui.fc.FileExtensionFilter and
    tjacobs.ui.fc.FileChooser.
    When I look at your code, I see the filename extension is appended in showSaveDialog:     public int showSaveDialog(Component c) {
                        setSelectedFile(new File(f.getAbsolutePath() + "." + ((FileExtensionFilter)filter).getType()));
        }It gets the extension by calling getType on the filter. But getType is implemented as:    public String getType () {
            return mExtensionList.get(0).toString();
        }So this returns the first type in the list. It does not check what filetype is selected by the combobox.
    Am I missing something?
    Also, in getDescription:    public String getDescription() {
            if (mDesc == null) {
                mDesc = "";
                for (int i = 0; i < mExtensionList.size(); i++) {
                    mDesc += (i != 0 ? ", " : "") + "." + mExtensionList.get(0).toString();
                mDesc+= " files";
            return mDesc;
        }you seem to iterate through the list, but only take the first entry every iteration.
    Can you explain mExtensionList.get(0)?
    Do you know how to test what type is selected in the JFileChooser's combobox?

Maybe you are looking for

  • How much recording time on my iphone 4 voice memo?

    How much recording time on iphone4 voice memo?

  • How do I get rid of the three SEO apps that are now on my computer?

    I'm not into internet marketing-building websites etc., at this time. I would like to remove the SEO apps that are on my desktop etc. I believe there are three of them, and I don't need them.

  • Photoshop CS3 Not showing up in Tools--

    I upgraded Dreamweaver only from CS3 to CS4, of course, it installed Bridge CS4, and I like the interface much better than CS3, I have Photoshop CS3, and want to use the Tools-->Photoshop-->Batch and Web Photo Gallery. but, in Bridge CS4, Photoshop a

  • Opencl under bootcamp

    I'm triyng to run reconstructme under win7 64bit in a bootcamp partition. An error appears as opencl.dll is missing. I tried then to install intel_sdk_applications_2013_beta_x64 and it works but it's slow. I tried to install last ATI AMD drivers for

  • Broadcasting the query

    Hi, There is a condition in the query. When it is executed in BEx, the report is correct. But, when it is broadcasted, the condition isnot taken into consideration and the report isnot correct. How to fix this issue? Thanks.