Write file on client

Hi all,
Is it possible to write a text file onto the client C drive from the portal?
The spec is; put 'download' button beside table, when clicked write table contents to an XML file, store on client for offline viewing later.
I wrote some code and it writes the file contents fine, creates a file and saves it on the server, obviously I want to save on the client for later use/display.
As always your help/input is appreciated.
Thanks,
Patrick.

Hi Gregor,
I figured it was browser security and obviously I wouldn't want every weebsite writing files to my harddisk.
Thanks for the input, I'll think about how to do this as comfortably as possible for the user. I'm almost certain we can't trust them to always save the file to the correct directory. I'll think about it.
Thanks again,
Patrick.

Similar Messages

  • How to write files on Client Machine using JSP

    Hi,
    I am new to JSP. Please tell me how do i write files on Client machine thru a Browser.
    Please let me know at the Earliest.
    Thanks.
    Mehul Dave

    1) Well I find it rather convenient to deploy a web app as just one file rather than a bunch of files. For deployment it's much better. However I prefer using expanded files when developping (to use auto reload in Tomcat for example)
    2) It is a bad idea to upload files inside your webapp's context (ie: in it's deployment directory) because one day an uninformed system administrator might come and redeploy the web app and therefore delete all your uploaded files (believe me, I've already experienced this!)
    What i do usually is upload it in a completely different directory, something like /uploaded_files. Your uploaded files are therefore completely independant from your webapp
    However it is a bit trickyer to get those files back. Let's take the example of image uploads. You have 2 ways of proceeding:
    - the easiest : configure your web server (apache etc...) to redirect a certain url to your external directory. For example the /upload url will point to a /uploaded_files directory. This is easier to do and the fastest way to serve images but not always the best solution: you are dependant on the web server's configuration and you can't control the visibility on your files (no security constraints, anyone can see your uploaded files if they know the url).
    - you can also write a servlet which will load the file as an array of bytes and send it back in the response.
    You can call it this way :
    <img src="/serlvets/showmyimage?path=uploaded.gif">
    in this way you can control your uploaded files better: you may want to define security constraints on the visibity or not of uploaded files depending on the user which has logged on the site.

  • Can you write an excel file on client machine instead of on the server

    I am trying to user cfSpreadSheet functon. The first question I have is, can you write the file on a client machine? I tried but they all end up on the server drive. Scecond question, is there a way to do row and column range formating in CF9.0? SpreadsheetFormatCellRange function is only available for ColdFusion server version 9.01.
    Thanks.

    To expand on Dan's answer: CF doesn't have any interaction with the client browser at all: client->server comms are handled by the client and the web server; the web server simply asks CF to provide the response data if the file requested is a CF file.  But even then all CF does is process the requested file and return data to the web server.
    Also, one of the restrictions of the HTTP protocol is that that there is *no* *way* that the server can write to the client machine.  All it can do is send data to the client agent (eg: a web browser) in response to the client agent requesting it.  Can you imagine the sort of security problems one would open one's self up to if a remote web server could write to your PC????
    Adam

  • Write a file on client from java procedure

    Hello to all, my problem is that i want to write a file from a java procedure using the normal java class. But when i try to write
    File file=new File("C:\\DiscoD\\myFile.txt");
    FileWriter fw=new FileWriter(file);
    fw.write("ciao");
    nothing happens and no file is created. How can i write a file on my pc client from java procedure?
    Thanks to anyone that want helps me.

    I want to write a java procedure loading java class on oracle with utility loadjava and this work for example for classical Hello World. Now i want to write data on a text file on my hard disk using class java calling the procedure for example in this mode:
    begin
    procedure('ciao'); //this procedure have to write on a file located on my pc the word ciao
    end;
    But nothing happens. Why? There is a special reason related to how oracle works(privileges, permission etc)?
    Thanks

  • Java applet writes to file on client, no signing necessary

    Hi,
    I wonder if this is a feature or bug:
    I download and execute in my browser an unsigned applet/jar myCharts.jar from server. The applet references classes from package org.jfree.chart, which are not packed in myCharts.jar downloaded from server, but are locally stored on client in jre/lib/ext/jfreechart.jar (and therefore JVM running the applet loads and uses these local classes from local jar).
    The applet can write the file to client disk without any problem using classes from locally loaded jfreechart.jar. If I merge both jars into a big one and load it through network, file write access is forbidden.
    I am using JRE 1.5.0.3 for Windows and default java_policy file with 2      permissions added:
    permission java.lang.RuntimePermission "accessDeclaredMembers";
    permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
    Is it a bug, or feature ?
    According to my opinion these 2 permissions should not result in applet ability to write files using locally loaded classes.
    Thanks for your answer
    Martin

    The following is a duplicate posting in reponse to similar question:
    http://forum.java.sun.com/thread.jsp?forum=4&thread=200482&start=0&range=30#735223
    In short, you cannot write to a server without help from servier-side software such as a servlet, cgi, ASP, etc.
    If you go with something like an Oracle database on your server, it's a non-issue because the seucirty aspects are taken care of for you.
    V.V.

  • Is thr way to applet write file, client machine without  entry in policy

    hi,
    is there any way to allow applet write file in local machine (client ) without entry in policy file... i feel this extra step to clients...
    To achieve this what are class i have to implements...

    No, thank God there isn't.

  • Remote Client Applet -Write File - Cannot be Done

    I've concluded that it is not possible for an applet embedded in a web-browser to write to a clients hard-disk no matter what you do with signing, policytool or RSA certificates.
    HD

    We can write, if the applet or jar file is signed

  • Write a text file on client

    I want to realise an applet which can write a text file on client. I use java 2 and an certified applet.
    I'm searching a script.
    If you have a solution or a script thank you.
    A+
    Ps: I'm french and sorry for my english

    FileOutputStream fos = new FileOutputStream(filname);
    DataOutputStream dos = new DataOutputStream(fos);
    try {
    dos.writeBytes("some string");
    } catch (Exception e) {
    out.println(e.toString());
    dos.close();
    fos.close();

  • How to read and write Xml file at client side using JavaScript !

    Hello,
    i am new to javascript.
    I have requirement to read and update XML file at client side.
    Will you please guide what could be the best way to read and update XMl file using javascript.
    Thanks,
    Zuned

    This is a Java forum,not a Javascript forum. Maybe you should ask here [http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s|http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s].

  • 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 upload file from client machine to  database in server machine?

    I am developing a web application. this application is suppose to take file from client machine and store that to database in the server side.
    My jsp form is of multi part type. but I am confused about what to write in servlet.
    Can any one help me ?
    Edited by: chinmaya_mishra on Feb 16, 2009 2:55 AM
    Edited by: chinmaya_mishra on Feb 16, 2009 2:58 AM

    http://www.google.com/search?q=jdbc+blob
    Blob processing varies between databases; see also examples for whatever database you are using, e.g.
    http://www.google.com/search?q=jdbc+blob+oracle
    If you are storing text data instead of binary data, replace "blob" by "clob" in the searches.

  • How to save a file in client system?

    I have a requiremnet like this:
    "When the user selects a file from his local drive (say c:\), I have to upload the file to a LAN connected to his machine."
    I have written the TestUpload class like below. It will work if my server is on the same machine. But, how can i do this if it is Unix Server?
    I was trying to do this for 2-3 days. Please help.
    protected void doGet(
    HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    HttpSession session = null;
    UploadListener listener = null;
    long contentLength = 0;
    System.out.println("I am inside doGet");
    if (
    ((session = request.getSession()) == null) ||
    listener =
    (UploadListener) session.getAttribute("LISTENER")
    ) == null
    ) || ((contentLength = listener.getContentLength()) < 1)) {
    out.write("");
    out.close();
    return;
    response.setContentType("text/html");
    long percentComplite =
    ((100 * listener.getBytesRead()) / contentLength);
    out.print(percentComplite);
    out.close();
    protected void doPost(
    HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    // create file upload factory and upload servlet
    FileItemFactory factory = new DiskFileItemFactory();
    ServletFileUpload upload = new ServletFileUpload(factory);
    // set file upload progress listener
    UploadListener listener = new UploadListener();
    HttpSession session = request.getSession();
    session.setAttribute("LISTENER", listener);
    // upload servlet allows to set upload listener
    upload.setProgressListener(listener);
    List items = null;
    FileItem fileItem = null;
    String filename = null;
    String fileName = null;
    String directory = null;
    String version = null;
    String fullPath = null;
    String extension = null;
    String folderName = null;
    try {
    // iterate over all uploaded files
    items = upload.parseRequest(request);
    for (Iterator i = items.iterator(); i.hasNext();) {
    fileItem = (FileItem) i.next();
    System.out.println("New file Item::: " + fileItem.getName());
    if (
    (fileItem.getName() != null) &&
    !fileItem.getName()
    .trim()
    .equals("")) {
    fullPath = fileItem.getName();
    extension = fullPath.substring(fullPath.lastIndexOf("."));
    directory = "\\\\MyLAN\\";
    fileName =
    fullPath.substring(
    fullPath.lastIndexOf("\\") + 1,
    fullPath.lastIndexOf("."));
    folderName = getFolderName(directory, fileName, extension);
    version =
    getVersionNumber(
    directory + folderName, fileName, extension);
    String strFilePath =
    directory + folderName + fileName + version +
    extension;
    System.out.println("path:: " + strFilePath);
              //Creating the destination File object.
    File file = new File(strFilePath);
    if (!fileItem.isFormField()) {
    if (fileItem.getSize() > 0) {
    // code that handle uploaded fileItem
    // don't forget to delete uploaded files after you done with them! Use fileItem.delete();
    fileItem.write(file);
    fileItem.delete();
                                       System.out.println("upload successful");
    // indicate that the upload was successfull
    writeLog(
    directory + folderName + "log.txt",
    now() + " ::: " + "Uploaded the version number:: " + version);
    response.getWriter()
    .write("upload successful");
    } catch (FileUploadException e) {
    response.getWriter()
    .write(e.getMessage());
    e.printStackTrace();
    } catch (Exception e) {
    response.getWriter()
    .write(e.getMessage());
    e.printStackTrace();
    } finally {
    session.removeAttribute("LISTENER");
    public String getFolderName(
    String directory, String fileName, String extension) {
    File dir = new File(directory);
    boolean folderFound = false;
    String foldername = null;
    String logFileName = "";
    File getFolderNames[] = dir.listFiles();
    for (int i = 0; i < getFolderNames.length; i++) {
    foldername = getFolderNames.getName();
    if (foldername.equalsIgnoreCase(fileName)) {
    folderFound = true;
    break;
    if (!folderFound) {
    File f = new File(directory + fileName);
    f.mkdir();
    f = new File(directory + fileName + "/log.txt");
    try {
    f.createNewFile();
    } catch (IOException e) {
    e.printStackTrace();
    logFileName = directory + fileName + "/log.txt";
    writeLog(logFileName, "***********************************");
    writeLog(logFileName, "Log for the file " + fileName);
    writeLog(logFileName, "***********************************\n\n");
    writeLog(logFileName, now() + " ::: " + "Created");
    return fileName + "\\";
    public String getVersionNumber(
    String directory, String fileName, String extension) {
    File dir = new File(directory);
    boolean fileFound = false;
    int version = 0;
    File getFolderNames[] = dir.listFiles();
    version = getFolderNames.length;
    return "_" + version;
    public void writeLog(String fileName, String text) {
    try {
    Writer output = null;
    File file = new File(fileName);
    output = new BufferedWriter(new FileWriter(fileName, true));
    output.write(text + "\n");
    output.close();
    System.out.println("Log file has been written");
    } catch (IOException e1) {
    e1.printStackTrace();
    Edited by: AnishThomas on Mar 12, 2008 10:52 PM

    Thanks for your reply!!!
    jwenting wrote:
    no, your code is NOT correct.
    It doesn't "upload" anything, as I stated before.It is working perfectly fine if the destination folder is connected to the server machine (which is not the case now).
    >
    Look into multipart MIME requests, Jakarta Commons File Upload, and things like that to actually upload files to a server instead of insisting on reading them directly from the client's filesystem in your servlet and wondering why that doesn't work if the servlet container is running on a different computer from the client.I AM using Jakarta Commons File Upload. The problem is when I try to access the destination folder(which is in client machine), it can't find as it is searching for the corresponding folder in the server.
    >
    Unless and until you do that, you're wasting our time and your own.I thought someone could help me i giving me some pointers which I missed. Thanks again!!
    Edited by: AnishThomas on Mar 14, 2008 8:13 AM

  • Is there any way to create files on client

    Hi,
    In a servlet class, I use java.net to get the client IP address, and I shared one folder on the client computer. But I got a java.io.IOException: Access is denied error when I was trying to create a file in the shared folder.
    I changed the java.policy to let the class have permission to write files. Any one can give me some suggestions?

    No server-side solution can help u! u should just use Applets.
    ( or any fat-client like a Java Application )
    --Behrad                                                                                                                                                                                                                                           

  • Not able to create a text file in Client Machine using Forms 10g

    Hi - I'm mot able to create a text file in Client Machine using Forms 10g. I'm getting error when system executes the bolded line.(i.e. CLIENT_TEXT_IO.FOPEN). During run-time system is throwing "ORA-06508: PL/SQL: could not find program unit being called".
    I had attached webutil.pll in the form.
    Please advise me.
    DECLARE
    l_Temp CLIENT_TEXT_IO.FILE_TYPE;
    LC$Name Varchar2(100) ;
    LC$Fic Varchar2(100) ;
    LN$Lines Pls_integer := 0 ;
    LC$Line Varchar2(4000) ;
    Cursor C_CUR Is
    Select * From TEST_TEXTIO where rownum <= 50;
    BEGIN
    LC$Name := 'tmp_file.txt' ;
    LC$Fic := 'c:\temp\tmp_file.txt';
    Begin
    l_temp := CLIENT_TEXT_IO.FOPEN( 'C:\temp\tmp_file.txt', 'W');
    Exception
         when others then
         message( 'OPEN FILE ERROR ' || LC$Fic ||sqlerrm );
         display_error;
         raise form_trigger_failure;
    End ;
    -- Write the lines --
    For Cur In C_CUR Loop
         LC$Line := Cur.CODE || ' -> ' || Cur.COL1 || ',' || Cur.COL2 || ',' || Cur.Col3 ;
         CLIENT_TEXT_IO.PUT_LINE( LF$File, LC$Line ) ;      
         LN$Lines := C_CUR%ROWCOUNT ;
    End loop ;
    -- Close the file --
    CLIENT_TEXT_IO.FCLOSE( LF$File ) ;
    Exception
         When others Then
    message('err='||sqlerrm);message(' ');
    display_error;
    CLIENT_TEXT_IO.FCLOSE( LF$File ) ;      
         Raise ;
    END;
    Thanks.
    Arun

    Hi ,
    i have one Question though its not related to thos question if some could help me it will be really helpful,
    i have created one program to import and export excel to forms vice versa, if the form is attached with webutil its working fine am using ole2.but i have a new idea if i add this program in menu, it can be used for all the forms attched to that menu, i made program also, but problem am facing right now is if the form is not attched with webutil it will not work so is there possiblity to share my webutil from one form to another form ,so i will keep one form as a interface form in that webutil will be attched ,i can share that webutil to all other forms so that all the forms no need to attach webutil again
    if its possible means please suggest some ideas

  • 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.

Maybe you are looking for

  • Printer won't print after a few mnutes

    Printer will consistently print just after it is turned on, but will NOT print after about 3-5 minutes. Printer goes to sleep but will wake up with a touch of the screen. If I try to turn off the printer, it often will not shut down without having to

  • Changes to program are forbidden by USER

    Good Morning Gurus. I have a program Z created by other guy. When i try Change this program then is showed the message: Changes to ZCX_FEBRABANT_REL are forbidden by ABA-FELIPE But This Guy ( ABA-FELIPE ) dont work in my company since 2008. How I can

  • Inside for-each loop

    hi, I gave one for-each loop inside one row, the table which am using has three columns and two rows, at first row there are column headings and second row first column i started for-each loop and ended end for-each loop at third column. Now I am get

  • Problem reading pdf files

    I'm having trouble opening some recent pdf files with Adobe Reader.  This is a problem that has only happened in the last few weeks. All my older pdf files open without any problem. However all my more recently downloaded pdf files will not open. I g

  • Cant open ogd files

    I have a form that has a embedded graphics object in it. When I try to load the graphics object I get the following error message: OG-01105: Can not find file c:\winnt\system32\DailyConsumption.ogd. I dont know why the application server is looking i