To open a file in applet

hi all,
Please help me to solve this problem. I have a button in applet called "open" which needs to open an image file present in my local system.In order to chose the file i have browse through the system.Please help me by providing sample code or any other way to do this...very urgent....
Regards

Applets cannot access local filesystem unless policy is set up by the user or if
the applet is signed and trusted.
You can use something like the JFilechooser to browse the clients local storage.
Signing applets:
http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
second post and reply 18 for the java class file using doprivileged
Still problems?
A Full trace might help us out:
http://forum.java.sun.com/thread.jspa?threadID=656028

Similar Messages

  • Can i open a file using applet?

    Hi,
    I try to open a file using applet.. but an error said "access denied(java.io.FilePermission tempecg.out, read) ...."
    tempecg.out is the file that I want to read.. below is part of my code.. what should I do...?
    currently the file is in my harddisk, next time will be linked using URL, will this be another problem?
    thanks!
    public void run()
    while (true)
    try
    LineNumberReader lr = new LineNumberReader(new FileReader("tempecg.out"));
    while (dv.size() < 240)
    int p = Integer.parseInt(lr.readLine().toString());
    //int p = (int)(Math.random() * 260);
    dv.add(new Point(0,p-130));
    Thread.sleep(2000);
    } catch (InterruptedException e) {}
    catch (IOException e) {}

    Hi pjustin1,
    you must use the policytool.exe given with JDK 1.2.x (or more).
    and with this tool you must add a permission on file (FilePermission) you want to access.
    Christophe.

  • Open html file from Applet

    Hi,
    I need to open html file from applet, the html file is placed in my local system, it is not open. the code is below, please can u tell where i did wrong.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    <applet code="Resource.class" width="400" height="400"></applet>
    public class Resource extends Applet implements ActionListener
    Button b = null;
    public void init(){
    b= new Button("Click");
    add(b);
    b.addActionListener(this);
    public void actionPerformed(ActionEvent ae){
    try
    URL adress = new URL(getDocumentBase(), "html_code.htm");
    getAppletContext().showDocument(adress, "_blank");
    System.out.println("Execut inside"+adress);
    }catch(MalformedURLException e){
    System.out.println("Eror in Display");
    }

    Don't cross post
    http://forum.java.sun.com/thread.jspa?threadID=633500

  • Opening .exe files in applets

    I am trying to open a .exe file using an applet I need help

    You can't do it. Applets are limited to execute native code
    Paul

  • File Upload applet not opening in Query Mode

    File Upload Applet is opening in Query Mode in Siebel 7.5, where as in Siebel 7.8 its not opening in Query Mode.
    Should anything be changed in CFG? or siebel restricted this?

    Hi,
    There is a property called "Auto Query Mode" in the applet. Check whether this has been set to "New Query" in 7.5. If so the applet will be opening in Query Mode automatically. If this property is blank, in 7.8, the applet will not be opening in Query mode. Check and let me know.
    Regards,
    Joseph

  • Opening image files in java applet

    Hi,
    I made an applet that opens up the image file and displays it.
    When the photo is loaded, the program sets boolean photoLoaded = true;
    and when the image is loaded, it has to do something else.
    the problem is that I have to open the file twice meaning I would click
    "open" button and select the photo, which doesn't do anything, so I have to go back
    and click open button, select the photo, and open up again.
    When I changed the code slightly so that it shows the first time, photoLoaded is still false the first time,
    so I still have to open it up twice for photoLoaded to be true.
    methods for opening an image file:
        private void loadPhoto() throws Exception{
            Frame parent = new Frame();
            FileDialog fd = new FileDialog(parent, "Please choose a image file:",
                FileDialog.LOAD);
            fd.show();
            String selectedImage = fd.getFile();
            if(selectedImage == null){
                // no image file selected
            }else{
                File ffile = new File(fd.getDirectory() + File.separator +
                                    fd.getFile());
                boolean canOpen = accept(ffile);
                if(canOpen){
                    imageLoaded = kit.getImage(selectedImage);
                    width = imageLoaded.getWidth(ob);
                    height = imageLoaded.getHeight(ob);
                    /*get image*/
                    imageLoaded = getImage(getCodeBase(), selectedImage);
                    tracker.addImage(imageLoaded, 0);
                    /* wait until image is loaded */
                    try{
                        tracker.waitForAll();
                        photoLoaded = true;
                    }catch(InterruptedException ex) {
                        //does nothing
                    repaint();
        public boolean accept(File f){
            if(f.isDirectory()){
                return true;
            String extension = Utils.getExtension(f);
            if(extension !=null){
                if(extension.equals(Utils.gif) ||
                   extension.equals(Utils.jpeg) ||
                   extension.equals(Utils.jpg)){
                       return true;
                } else{
                    return false;
            return false;
        public static class Utils{
            public final static String jpeg = "jpeg";
            public final static String jpg = "jpg";
            public final static String gif = "gif";
            /* get the extension of a file */
            public static 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;
        }and the paint method:
        public void paint(Graphics g)
            g.drawImage(background, 0, 0, this);
            if(photoLoaded == true){
                g.drawImage(imageLoaded, startingPtX, startingPtY, ob);
        }does anybody have idea on what's wrong with it?
    thanks!

    Is this what you mean by you have to load it twice? You load the image, then add it to the MediaTracker, then you do what ever you want with it--like get the width and height and set you flags.
       imageLoaded = kit.getImage(selectedImage);
       width = imageLoaded.getWidth(ob);
       height = imageLoaded.getHeight(ob);
       /*get image*/
       imageLoaded = getImage(getCodeBase(), selectedImage);
       tracker.addImage(imageLoaded, 0);

  • Can I use Desktop.getDesktop().open(file) to open a file instead of Applet

    Hi
    I was assigned a task in which a file has to be downloaded from a server. Right now, the code was already there which is written using applet. That is file is downloaded to local directory then it will get opened. Why cant I code in the following way.
    1. Reading the file from the server and writing it to a local directory.
    2. Opening the file from that directory using Desktop.getDesktop().open(file)
    Since I am a newbie to java i could not understand the difference between these two things.
    can anyone please explain me so that i can proceed with the right way.
    Thanks in Advance.

    Dinesh wrote:
    Hi
    I was assigned a task in which a file has to be downloaded from a server. Right now, the code was already there which is written using applet. That is file is downloaded to local directory then it will get opened. Why cant I code in the following way.
    1. Reading the file from the server and writing it to a local directory.
    2. Opening the file from that directory using Desktop.getDesktop().open(file)This is highly confusing. What you describe is what is apparently implemented in this applet. So what do you want to code differently? And WHERE do you want to run this code? There must be a reason why it is right now an applet. Are you talking about a web environment like servlets/JSPs?

  • Open drawing file of ideas,nx4,catia in applet

    I am developing one application in which i want to open any engineering drawing/model file on applet.
    Plz. Can anybody help me in this.......

    The official CATIA applet based viewer renders it on the server using CATIA, then passes the image to the client. Do you licensed versions of the software you're rendering the files of, or is this a reverse engineering effort?

  • Unable to open desktop file /usr/share/applications/redhat-email.desktop for panel launcher: No such file or directory

    Dear Experts,
    Please note that I am facing a chllenge while confiuguring the VNCServer on the local test Server. The Local Test Sver OS Version is Redhat Enterprise Linux Server 
    Release 5.5 32-bit. Please review the following error message and advise me on how to fix the vncserver issue.
    [root@test .vnc]#  cat xstartup
    #!/bin/sh
    # Uncomment the following two lines for normal desktop:
    unset SESSION_MANAGER
    exec /etc/X11/xinit/xinitrc
    gnome-session &
    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    xsetroot -solid grey
    vncconfig -iconic &
    #xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    twm &
    [root@test .vnc]#  cat /etc/sysconfig/vncservers
    # The VNCSERVERS variable is a list of display:user pairs.
    # Uncomment the lines below to start a VNC server on display :2
    # as my 'myusername' (adjust this to your own).  You will also
    # need to set a VNC password; run 'man vncpasswd' to see how
    # to do that.
    # DO NOT RUN THIS SERVICE if your local area network is
    # untrusted!  For a secure way of using VNC, see
    # <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.
    # Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
    # Use "-nohttpd" to prevent web-based VNC clients connecting.
    # Use "-localhost" to prevent remote VNC clients connecting except when
    # doing so through a secure tunnel.  See the "-via" option in the
    # `man vncviewer' manual page.
    # VNCSERVERS="2:myusername"
    # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
    VNCSERVERS="1:oracle"
    [root@test .vnc]# ls
    passwd test.oracle.co.zm:1.pid  test.oracle.co.zm:3.log  test.oracle.co.zm:5.pid  test.oracle.co.zm:6.pid
    test.oracle.co.zm:1.log test.oracle.co.zm:2.log  test.oracle.co.zm:5.log  test.oracle.co.zm:6.log  xstartup
    [root@test .vnc]# more test.oracle.co.zm:1.log
    Xvnc Free Edition 4.1.2
    Copyright (C) 2002-2005 RealVNC Ltd.
    See http://www.realvnc.com for information on VNC.
    Underlying X server release 70101000, The X.Org Foundation
    Tue Mar 11 11:18:37 2014
    vncext:      VNC extension running!
    vncext:      Listening for VNC connections on port 5901
    vncext:      Listening for HTTP connections on port 5801
    vncext:      created VNC server for screen 0
    Could not init font path element unix/:7100, removing from list!
    localuser:root being added to access control list
    No profile for user 'root' found
    SESSION_MANAGER=local/test.oracle.co.zm:/tmp/.ICE-unix/13603
    Window manager warning: Log level 32: could not find XKB extension.
    ** (eggcups:13671): WARNING **: IPP request failed with status 1030
    ** (eggcups:13671): WARNING **: IPP request failed with status 1030
    ** (nm-applet:13697): WARNING **: No connections defined
    Initializing nautilus-open-terminal extension
    Unable to open desktop file /usr/share/applications/redhat-email.desktop for panel launcher: No such file or directory
    Unable to open desktop file /usr/share/applications/openoffice.org-1.9-writer.desktop for panel launcher: No such file or directory
    Unable to open desktop file /usr/share/applications/openoffice.org-1.9-impress.desktop for panel launcher: No such file or directory
    Unable to open desktop file /usr/share/applications/openoffice.org-1.9-calc.desktop for panel launcher: No such file or directory
    [root@test .vnc]#
    Regards
    Mohammed Abdul Muqeet

    Hi,
    Try these 3 solutions
    1. Did you start vncserver services as:
    service vncserver start
    2.Check that port 5901 has not been blocked by a firewall:
    # nc -vz localhost 5901
    You should get a connection and a termination. If you get an error, fix the firewall.
    3. service iptables stop
    Hope This Helps
    Regards,
    -DK

  • Can not open JAR file?

    Hello,
    My friend and I are working on a Calculus Project in which he made a Java applet that shows how a function's derivative is found... regardless! He made this file on a Linux based computer and saved it as a .jar file and sent to me via email. I downloaded the file and double clicked it, but the file didnt open, instead it displayed this message:
    "The Java JAR File "Calc_Deriv.jar" could not be launched.
    Please check the console for possible errors"
    I checked the console, and to be honest I had absolutely no clue what I was looking at. Here were the messages from the last 10 minutes.
    Code:
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] SystemFlippers: didn't consume all data for long ID 0 (pBase = 0x10012fc90, p = 0x10012fc94, pEnd = 0x10012fc98)
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] SystemFlippers: didn't consume all data for long ID 0 (pBase = 0x1001116f0, p = 0x1001116f4, pEnd = 0x1001116f8)
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] Exception in thread "main"
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] java.lang.NoClassDefFoundError: org/jdesktop/application/SingleFrameApplication
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] at java.lang.ClassLoader.defineClass2(Native Method)
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] at java.lang.ClassLoader.defineClass(ClassLoader.java:774)
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:160 )
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] at java.net.URLClassLoader.defineClass(URLClassLoader.java:254)
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] at java.security.AccessController.doPrivileged(Native Method)
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
    12/15/09 6:01:11 PM [0x0-0x10d10d].com.apple.JarLauncher[3275] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    I do not know where to start, nor where to end, nor what I am looking for. But essentially I simply need to open this file and see what is inside.
    --System--
    Model Name: MacBook Pro
    Model Identifier: MacBookPro4,1
    Processor Name: Intel Core 2 Duo
    Processor Speed: 2.4 GHz
    Number Of Processors: 1
    Total Number Of Cores: 2
    L2 Cache: 3 MB
    Memory: 2 GB
    Bus Speed: 800 MHz
    Boot ROM Version: MBP41.00C1.B03
    SMC Version (system): 1.27f2
    Serial Number (system): W8**T1YJX
    Hardware UUID: 9FC62D3C-021A-5C2A-9197-134226381FE9
    Mac OSX 10.5.8
    Thank you very much for the help!

    In a Terminal session you could try something like
    unzip -l path/to/jar/file
    Dave

  • Script to open excel files take info and put into new document

    Hi All
    I am new to applescript, but looking through the forums it seems to be the solution to my problem.
    I have large numbers of excel files on a pc server which i want to open, take approx 8 cells of information from each and place into a new excel doc, forming a list. I want this if possible to happen automatically, so if a new excel document is placed into a folder on the server, the relavent information is added to my list.
    I have looked at automator but dont think it works with excel yet, and the programming in excel is too much for me.
    I posted a query here in my previous job for a script of change all "/" symbols to "-" symbols, which worked very well and i hope someone more gifted can help with my new query.
    Hope i have given enough info and that someone can help
    thanks

    Supplied below is a, quick and dirty (minimal error handling), working self contained (applet) example:
    on run {}
    display dialog "Drag files onto applet for processing."
    end run
    on open (dragged_Items)
    try
    tell application "Microsoft Excel" -- Launch 'Excel' to process '.xls' files
    set tList to {} -- Create an empty list.
    repeat with i in dragged_Items -- Cycle through each dragged '.xls' file.
    open i -- Open each file.
    repeat with j from 1 to 8 -- Cycle through the eight column values of a single row.
    copy (value of cell j of row 3) to end of tList -- Obtain individul cells' value and place into 'tList'.
    end repeat
    end repeat
    repeat until (documents is {}) -- Routine to close all opened '.xls' windows. Here, 'close windows' does not work.
    close windows
    end repeat
    if (not (document 1 exists)) then make new document -- Create a new document, if needed.
    set k to 0 -- Location (position) of a 'tList' item.
    repeat with i from 1 to (count dragged_Items) -- Set row value, of where to ener column values.
    repeat with j from 1 to 8 -- Set cells' column value.
    set k to k + 1 -- Increment 'tList' location.
    set (value of cell j of row i) to (item k of tList) -- Enter value into current rows' columns' cell from 'tList'.
    end repeat
    end repeat
    activate -- Bring window to foreground.
    end tell
    end try
    end open
    Save the AppleScript code as an applet (application).
    Drag the desired files onto the applet for processing.
    The above AppleScript code obtains the cell values of columns A through H of row 3 of each '.xls' file.
    To automatically process the files of a specific folder - utilize the provided code, with respective modifications, within a
    'on adding folder items to this_folder after receiving these_items
    end adding folder items to
    ... AppleScript - 'Folder Action'.

  • Uploading large files from applet to servlet throws out of memory error

    I have a java applet that needs to upload files from a client machine
    to a web server using a servlet. the problem i am having is that in
    the current scheme, files larger than 17-20MB throw an out of memory
    error. is there any way we can get around this problem? i will post
    the client and server side code for reference.
    Client Side Code:
    import java.io.*;
    import java.net.*;
    // this class is a client that enables transfer of files from client
    // to server. This client connects to a servlet running on the server
    // and transmits the file.
    public class fileTransferClient
    private static final String FILENAME_HEADER = "fileName";
    private static final String FILELASTMOD_HEADER = "fileLastMod";
    // this method transfers the prescribed file to the server.
    // if the destination directory is "", it transfers the file to
    "d:\\".
    //11-21-02 Changes : This method now has a new parameter that
    references the item
    //that is being transferred in the import list.
    public static String transferFile(String srcFileName, String
    destFileName,
    String destDir, int itemID)
    if (destDir.equals(""))
    destDir = "E:\\FTP\\incoming\\";
    // get the fully qualified filename and the mere filename.
    String fqfn = srcFileName;
    String fname =
    fqfn.substring(fqfn.lastIndexOf(File.separator)+1);
    try
    //importTable importer = jbInit.getImportTable();
    // create the file to be uploaded and a connection to
    servlet.
    File fileToUpload = new File(fqfn);
    long fileSize = fileToUpload.length();
    // get last mod of this file.
    // The last mod is sent to the servlet as a header.
    long lastMod = fileToUpload.lastModified();
    String strLastMod = String.valueOf(lastMod);
    URL serverURL = new URL(webadminApplet.strServletURL);
    URLConnection serverCon = serverURL.openConnection();
    // a bunch of connection setup related things.
    serverCon.setDoInput(true);
    serverCon.setDoOutput(true);
    // Don't use a cached version of URL connection.
    serverCon.setUseCaches (false);
    serverCon.setDefaultUseCaches (false);
    // set headers and their values.
    serverCon.setRequestProperty("Content-Type",
    "application/octet-stream");
    serverCon.setRequestProperty("Content-Length",
    Long.toString(fileToUpload.length()));
    serverCon.setRequestProperty(FILENAME_HEADER, destDir +
    destFileName);
    serverCon.setRequestProperty(FILELASTMOD_HEADER, strLastMod);
    if (webadminApplet.DEBUG) System.out.println("Connection with
    FTP server established");
    // create file stream and write stream to write file data.
    FileInputStream fis = new FileInputStream(fileToUpload);
    OutputStream os = serverCon.getOutputStream();
    try
    // transfer the file in 4K chunks.
    byte[] buffer = new byte[4096];
    long byteCnt = 0;
    //long percent = 0;
    int newPercent = 0;
    int oldPercent = 0;
    while (true)
    int bytes = fis.read(buffer);
    byteCnt += bytes;
    //11-21-02 :
    //If itemID is greater than -1 this is an import file
    transfer
    //otherwise this is a header graphic file transfer.
    if (itemID > -1)
    newPercent = (int) ((double) byteCnt/ (double)
    fileSize * 100.0);
    int diff = newPercent - oldPercent;
    if (newPercent == 0 || diff >= 20)
    oldPercent = newPercent;
    jbInit.getImportTable().displayFileTransferStatus
    (itemID,
    newPercent);
    if (bytes < 0) break;
    os.write(buffer, 0, bytes);
    os.flush();
    if (webadminApplet.DEBUG) System.out.println("No of bytes
    sent: " + byteCnt);
    finally
    // close related streams.
    os.close();
    fis.close();
    if (webadminApplet.DEBUG) System.out.println("File
    Transmission complete");
    // find out what the servlet has got to say in response.
    BufferedReader reader = new BufferedReader(
    new
    InputStreamReader(serverCon.getInputStream()));
    try
    String line;
    while ((line = reader.readLine()) != null)
    if (webadminApplet.DEBUG) System.out.println(line);
    finally
    // close the reader stream from servlet.
    reader.close();
    } // end of the big try block.
    catch (Exception e)
    System.out.println("Exception during file transfer:\n" + e);
    e.printStackTrace();
    return("FTP failed. See Java Console for Errors.");
    } // end of catch block.
    return("File: " + fname + " successfully transferred.");
    } // end of method transferFile().
    } // end of class fileTransferClient
    Server side code:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.net.*;
    // This servlet class acts as an FTP server to enable transfer of
    files
    // from client side.
    public class FtpServerServlet extends HttpServlet
    String ftpDir = "D:\\pub\\FTP\\";
    private static final String FILENAME_HEADER = "fileName";
    private static final String FILELASTMOD_HEADER = "fileLastMod";
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException,
    IOException
    doPost(req, resp);
    public void doPost(HttpServletRequest req, HttpServletResponse
    resp)
    throws ServletException,
    IOException
    // ### for now enable overwrite by default.
    boolean overwrite = true;
    // get the fileName for this transmission.
    String fileName = req.getHeader(FILENAME_HEADER);
    // also get the last mod of this file.
    String strLastMod = req.getHeader(FILELASTMOD_HEADER);
    String message = "Filename: " + fileName + " saved
    successfully.";
    int status = HttpServletResponse.SC_OK;
    System.out.println("fileName from client: " + fileName);
    // if filename is not specified, complain.
    if (fileName == null)
    message = "Filename not specified";
    status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    else
    // open the file stream for the file about to be transferred.
    File uploadedFile = new File(fileName);
    // check if file already exists - and overwrite if necessary.
    if (uploadedFile.exists())
    if (overwrite)
    // delete the file.
    uploadedFile.delete();
    // ensure the directory is writable - and a new file may be
    created.
    if (!uploadedFile.createNewFile())
    message = "Unable to create file on server. FTP failed.";
    status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    else
    // get the necessary streams for file creation.
    FileOutputStream fos = new FileOutputStream(uploadedFile);
    InputStream is = req.getInputStream();
    try
    // create a buffer. 4K!
    byte[] buffer = new byte[4096];
    // read from input stream and write to file stream.
    int byteCnt = 0;
    while (true)
    int bytes = is.read(buffer);
    if (bytes < 0) break;
    byteCnt += bytes;
    // System.out.println(buffer);
    fos.write(buffer, 0, bytes);
    // flush the stream.
    fos.flush();
    } // end of try block.
    finally
    is.close();
    fos.close();
    // set last mod date for this file.
    uploadedFile.setLastModified((new
    Long(strLastMod)).longValue());
    } // end of finally block.
    } // end - the new file may be created on server.
    } // end - we have a valid filename.
    // set response headers.
    resp.setContentType("text/plain");
    resp.setStatus(status);
    if (status != HttpServletResponse.SC_OK)
    getServletContext().log("ERROR: " + message);
    // get output stream.
    PrintWriter out = resp.getWriter();
    out.println(message);
    } // end of doPost().
    } // end of class FtpServerServlet

    OK - the problem you describe is definitely what's giving you grief.
    The workaround is to use a socket connection and send your own request headers, with the content length filled in. You may have to multi-part mime encode the stream on its way out as well (I'm not about that...).
    You can use the following:
    http://porsche.cis.udel.edu:8080/cis479/lectures/slides-04/slide-02.html
    on your server to get a feel for the format that the request headers need to take.
    - Kevin
    I get the out of Memory Error on the client side. I
    was told that this might be a bug in the URLConnection
    class implementation that basically it wont know the
    content length until all the data has been written to
    the output stream, so it uses an in memory buffer to
    store the data which basically causes memory issues..
    do you think there might be a workaround of any kind..
    or maybe a way that the buffer might be flushed after
    a certain size of file has been uploaded.. ?? do you
    have any ideas?

  • Open a file in UNC path from jsp page

    Hi,
    it might be simple but I don't know how i can achieve this,
    I have a UNC path to a remote computer something like this,
    \\ComputerName\SharedFolder\ResourceFileName
    i can open this file from windows by typing the above in Windowes explorer or something like this in browser file://ComputerName/SharedFolder/myfile.txt
    I want a simple jsp page that will have a hyperlink or a button which when clicked should prompt me with a dialog to open/save/cancel the file. it should not open the text fine inside the browser itself. when i click open it should open the file in appropriate viewer(i think this is judged by the mimetypes set on my machine).
    Thanks in Advance.

    khana6454 wrote:
    I want a simple jsp page that will have a hyperlink or a button which when clicked should prompt me with a dialog to open/save/cancel the file. it should not open the text fine inside the browser itself. when i click open it should open the file in appropriate viewer(i think this is judged by the mimetypes set on my machine).You need to set the content disposition to 'attachment' rather than 'inline' (which is default).
    You may find this FileServlet example useful: [http://balusc.blogspot.com/2007/07/fileservlet.html].
    That said, the file needs to be located on the server machine, not on the client machine. If you want to open files from the client machine, rather write a client side application which you can integrate in your webpage, e.g. a signed applet or web start application (jnlp).

  • Playing an audio file from applet

    Hi friends,
    I have a problem to be solved .
    Please help me.
    I have to play an audio file from applet.When the applet loads it shold start playing .There is a progress bar in the applet it shold alsomove corresponding to that.
    How can i do that.Give me an idea.
    I know nothing about jmf.
    I am using j2sdk1.4,windows 2000 server.

    Andrew,
    Forgive my naivety, but i struggle with JAVA! I am desperately trying to create a JAVA plugin to SERVOY and have to date been successful with a few things. Record, Playback, convert to .spx.
    I am really struggling with implementing a rewind and fastforward function of the type you have. I thought it would be easy, but it appears not.
    At the bottom is the complete code from my class that is called by the servoy plugin wrapper,
    i had thought that adding some simple jump 500 ms would have been easy in something like this:
    public AudioStream js_FastForward (AudioStream as) throws IOException {
    !!! Line or two here to move the play head forward !!!
         AudioPlayer.player.start(as);
         return as;
    Can you give me any pointers to how i code that fast forward bit.
    many thanks
    David
    package com.d2e.MyPlugin;
    import com.servoy.j2db.scripting.IScriptObject;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.awt.Button;
    import javax.sound.sampled.*;
    import org.xiph.speex.*;
    import org.xiph.speex.spi.*;
    import  sun.audio.*;    //import the sun.audio package
    public class MyPluginProvider implements IScriptObject  {
          public void JSencode()
             throws IOException{
               /** Version of the Speex Encoder */
                final String VERSION = "Java Speex Command Line Encoder v0.9.7 ($Revision: 1.5 $)";
                /** Copyright display String */
                final String COPYRIGHT = "Copyright (C) 2002-2004 Wimba S.A.";
                /** Print level for messages : Print debug information */
                final int DEBUG = 0;
                /** Print level for messages : Print basic information */
                final int INFO  = 1;
                /** Print level for messages : Print only warnings and errors */
                final int WARN  = 2;
                /** Print level for messages : Print only errors */
                final int ERROR = 3;
                int printlevel = INFO;
                /** File format for input or output audio file: Raw */
                final int FILE_FORMAT_RAW  = 0;
                /** File format for input or output audio file: Ogg */
                final int FILE_FORMAT_OGG  = 1;
                /** File format for input or output audio file: Wave */
                final int FILE_FORMAT_WAVE = 2;
                int srcFormat  = FILE_FORMAT_OGG;
                int destFormat = FILE_FORMAT_WAVE;
                int mode       = -1;
                int quality    = 4;
                /** Defines the encoders algorithmic complexity. */
                 int complexity = 3;
                /** Defines the number of frames per speex packet. */
                 int nframes    = 1;
                /** Defines the desired bitrate for the encoded audio. */
                 int bitrate    = -1;
                /** Defines the sampling rate of the audio input. */
                 int sampleRate = -1;
                /** Defines the number of channels of the audio input (1=mono, 2=stereo). */
                 int channels   = 1;
                /** Defines the encoder VBR quality setting (float from 0 to 10). */
                 float vbr_quality = -1;
                /** Defines whether or not to use VBR (Variable Bit Rate). */
                 boolean vbr    = false;
                /** Defines whether or not to use VAD (Voice Activity Detection). */
                 boolean vad    = false;
                /** Defines whether or not to use DTX (Discontinuous Transmission). */
                 boolean dtx    = false;
              //HArd code src format and dest
               // private String srcPath ="junk.wav";
              srcFormat = FILE_FORMAT_WAVE;
              destFormat = FILE_FORMAT_OGG;
              //destPath="junk.spx";
             byte[] temp    = new byte[2560]; // stereo UWB requires one to read 2560b
             final int HEADERSIZE = 8;
             final String RIFF      = "RIFF";
             final String WAVE      = "WAVE";
             final String FORMAT    = "fmt ";
             final String DATA      = "data";
             final int WAVE_FORMAT_PCM = 0x0001;
             // Open the input stream
             DataInputStream dis = new DataInputStream(new FileInputStream("junk.wav"));
             // Prepare input stream
           //DP - Sort out the Wave File
               // read the WAVE header
               dis.readFully(temp, 0, HEADERSIZE+4);
               // Read other header chunks
               dis.readFully(temp, 0, HEADERSIZE);
               String chunk = new String(temp, 0, 4);
               int size = readInt(temp, 4);
               while (!chunk.equals(DATA)) {
                 dis.readFully(temp, 0, size);
                 if (chunk.equals(FORMAT)) {
                   typedef struct waveformat_extended_tag {
                   WORD wFormatTag; // format type
                   WORD nChannels; // number of channels (i.e. mono, stereo...)
                   DWORD nSamplesPerSec; // sample rate
                   DWORD nAvgBytesPerSec; // for buffer estimation
                   WORD nBlockAlign; // block size of data
                   WORD wBitsPerSample; // Number of bits per sample of mono data
                   WORD cbSize; // The count in bytes of the extra size
                   } WAVEFORMATEX;
                   if (readShort(temp, 0) != WAVE_FORMAT_PCM) {
                     System.err.println("Not a PCM file");
                     return;
                   channels = readShort(temp, 2);
                   sampleRate = readInt(temp, 4);
                   if (readShort(temp, 14) != 16) {
                     System.err.println("Not a 16 bit file " + readShort(temp, 18));
                     return;
                   // Display audio info
                   if (printlevel <= DEBUG) {
                     System.out.println("File Format: PCM wave");
                     System.out.println("Sample Rate: " + sampleRate);
                     System.out.println("Channels: " + channels);
                 dis.readFully(temp, 0, HEADERSIZE);
                 chunk = new String(temp, 0, 4);
                 size = readInt(temp, 4);
               if (printlevel <= DEBUG) System.out.println("Data size: " + size);
           //DP ENd sort wave file 
           //Now Choose the mode , we have a file sampled at 44100
                 mode = 2; // Ultra-wideband
             // Construct a new encoder
             SpeexEncoder speexEncoder = new SpeexEncoder();
             speexEncoder.init(mode, quality, sampleRate, channels);
             if (complexity > 0) {
               speexEncoder.getEncoder().setComplexity(complexity);
             if (bitrate > 0) {
               speexEncoder.getEncoder().setBitRate(bitrate);
             if (vbr) {
               speexEncoder.getEncoder().setVbr(vbr);
               if (vbr_quality > 0) {
                 speexEncoder.getEncoder().setVbrQuality(vbr_quality);
             if (vad) {
               speexEncoder.getEncoder().setVad(vad);
             if (dtx) {
               speexEncoder.getEncoder().setDtx(dtx);
             // Display info
             // Open the file writer
             AudioFileWriter writer;
             if (destFormat == FILE_FORMAT_OGG) {
               writer = new OggSpeexWriter(mode, sampleRate, channels, nframes, vbr);
             else if (destFormat == FILE_FORMAT_WAVE) {
               nframes = PcmWaveWriter.WAVE_FRAME_SIZES[mode-1][channels-1][quality];
               writer = new PcmWaveWriter(mode, quality, sampleRate, channels, nframes, vbr);
             else {
               writer = new RawWriter();
             writer.open("junk.spx");
             writer.writeHeader("Encoded with: " + VERSION);
             int pcmPacketSize = 2 * channels * speexEncoder.getFrameSize();
             try {
               // read until we get to EOF
               while (true) {
                 dis.readFully(temp, 0, nframes*pcmPacketSize);
                 for (int i=0; i<nframes; i++)
                   speexEncoder.processData(temp, i*pcmPacketSize, pcmPacketSize);
                 int encsize = speexEncoder.getProcessedData(temp, 0);
                 if (encsize > 0) {
                   writer.writePacket(temp, 0, encsize);
             catch (EOFException e) {}
             writer.close();
             dis.close();
            * Converts Little Endian (Windows) bytes to an int (Java uses Big Endian).
            * @param data the data to read.
            * @param offset the offset from which to start reading.
            * @return the integer value of the reassembled bytes.
           protected static int readInt(final byte[] data, final int offset)
             return (data[offset] & 0xff) |
                    ((data[offset+1] & 0xff) <<  8) |
                    ((data[offset+2] & 0xff) << 16) |
                    (data[offset+3] << 24); // no 0xff on the last one to keep the sign
            * Converts Little Endian (Windows) bytes to an short (Java uses Big Endian).
            * @param data the data to read.
            * @param offset the offset from which to start reading.
            * @return the integer value of the reassembled bytes.
           protected static int readShort(final byte[] data, final int offset)
             return (data[offset] & 0xff) |
                    (data[offset+1] << 8); // no 0xff on the last one to keep the sign
         AudioFormat audioFormat;
           TargetDataLine targetDataLine;
         public Class[] getAllReturnedTypes() {
              // TODO Auto-generated method stub
              return null;
         public String[] getParameterNames(String arg0) {
              // TODO Auto-generated method stub
              return null;
         public String getSample(String arg0) {
              // TODO Auto-generated method stub
              return null;
         public String getToolTip(String arg0) {
              // TODO Auto-generated method stub
              return null;
         public boolean isDeprecated(String arg0) {
              // TODO Auto-generated method stub
              return false;
         public String js_Record (String name){
              captureAudio();
              return "Started Recording " +name;
        public String js_StopRecord (String name) throws IOException{
             //new ActionListener(){
             //   public void actionPerformed(ActionEvent e)
                  //Terminate the capturing of input data
                  // from the microphone.
                  targetDataLine.stop();
                  targetDataLine.close();
              //  }//end actionPerformed
             //};//end ActionListener
                 // JSpeexEnc ("junk.wav","output.spx");
                  JSencode();
              return "Stop Records " +name;
        //Play audio file
        public AudioStream js_Playback (String name) throws IOException{
             InputStream in = new FileInputStream("junk.wav");
             AudioStream as = new AudioStream(in);        
             AudioPlayer.player.start(as);           
             return as;
        public AudioStream js_ContPlay (AudioStream as) throws IOException {
             AudioPlayer.player.start(as);           
             return as;
         //Stop Play
        public AudioStream js_Stop_Playback (AudioStream as) throws IOException{
             AudioPlayer.player.stop(as);
              return as;
         //This method captures audio input from a
        // microphone and saves it in an audio file.
        private void captureAudio(){
          try{
            //Get things set up for capture
            audioFormat = getAudioFormat();
            DataLine.Info dataLineInfo =
                                new DataLine.Info(
                                  TargetDataLine.class,
                                  audioFormat);
            targetDataLine = (TargetDataLine)
                     AudioSystem.getLine(dataLineInfo);
            //Create a thread to capture the microphone
            // data into an audio file and start the
            // thread running.  It will run until the
            // Stop button is clicked.  This method
            // will return after starting the thread.
            new CaptureThread().start();
          }catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
          }//end catch
        }//end captureAudio method  
    //  This method creates and returns an
        // AudioFormat object for a given set of format
        // parameters.  If these parameters don't work
        // well for you, try some of the other
        // allowable parameter values, which are shown
        // in comments following the declarations.
        private AudioFormat getAudioFormat(){
          float sampleRate = 44100.0F;
          //8000,11025,16000,22050,44100
          int sampleSizeInBits = 16;
          //8,16
          int channels = 1;
          //1,2
          boolean signed = true;
          //true,false
          boolean bigEndian = true;
          //true,false
          return new AudioFormat(sampleRate,
                                 sampleSizeInBits,
                                 channels,
                                 signed,
                                 bigEndian);
        }//end getAudioFormat
        class CaptureThread extends Thread{
               public void run(){
                 AudioFileFormat.Type fileType = null;
                 File audioFile = null;
                 //Set the file type and the file extension
                 // based on the selected radio button.
                 //if(aifcBtn.isSelected()){
                  // fileType = AudioFileFormat.Type.AIFC;
                  // audioFile = new File("junk.aifc");
                // }else if(aiffBtn.isSelected()){
                 //  fileType = AudioFileFormat.Type.AIFF;
                 //  audioFile = new File("junk.aif");
                // }else if(auBtn.isSelected()){
                 //  fileType = AudioFileFormat.Type.AU;
                 //  audioFile = new File("junk.au");
                // }else if(sndBtn.isSelected()){
                //   fileType = AudioFileFormat.Type.SND;
                 //  audioFile = new File("junk.snd");
                // }else if(waveBtn.isSelected()){
                 fileType = AudioFileFormat.Type.WAVE;
                 audioFile = new File("junk.wav");
                // }//end if
                 try{
                   targetDataLine.open(audioFormat);
                   targetDataLine.start();
                   AudioSystem.write(
                         new AudioInputStream(targetDataLine),
                         fileType,
                         audioFile);
                 }catch (Exception e){
                   e.printStackTrace();
                 }//end catch
               }//end run
             }//end inner class CaptureThread
    }

  • I am unable to open PDF files or run adobe flash when its needed I have downloaded it several times and tried updating it.

    I am unable to open PDF files or run adobe flash when its needed I have downloaded it several times and tried updating it. NEED HELP

    Adobe Acrobat NPAPI Plug-in, Version 11.0.04
    Adobe® Acrobat® Plug-in for Web Browsers, Version 11.0.04 — from file “AdobePDFViewerNPAPI.plugin”.
    application/pdf
    Acrobat Portable Document Format
    pdf
    application/vnd.adobe.pdf
    Acrobat Portable Document Format (Interim)
    pdf
    application/vnd.adobe.pdfxml
    Acrobat XML Portable Document Format
    pdfxml
    application/vnd.adobe.x-mars
    Acrobat XML Portable Document Format (Interim)
    mars
    application/vnd.adobe.xdp+xml
    XML Data Package
    xdp
    application/vnd.adobe.xfd+xml
    FormFlow99 Data File
    xfd
    application/vnd.adobe.xfdf
    Acrobat Forms Data Format in XML
    xfdf
    application/vnd.fdf
    Acrobat Forms Data Format
    fdf
    doubleTwist Web Plugin
    doubleTwist Web Plugin — from file “doubleTwistWebPlugin.bundle”.
    application/x-vnd-doubletwist
    doubleTwist Web Plugin
    Java Applet Plug-in
    Displays Java applet content, or a placeholder if Java is not installed. — from file “JavaAppletPlugin.plugin”.
    application/x-java-applet
    Basic Java Applets
    javaapplet
    application/x-java-applet;deploy=10.25.2
    Java applet
    application/x-java-applet;javafx=2.2.25
    Java applet
    application/x-java-applet;jpi-version=1.7.0_25
    Java applet
    application/x-java-applet;version=1.1
    Java applet
    application/x-java-applet;version=1.1.1
    Java applet
    application/x-java-applet;version=1.1.2
    Java applet
    application/x-java-applet;version=1.1.3
    Java applet
    application/x-java-applet;version=1.2
    Java applet
    application/x-java-applet;version=1.2.1
    Java applet
    application/x-java-applet;version=1.2.2
    Java applet
    application/x-java-applet;version=1.3
    Java applet
    application/x-java-applet;version=1.3.1
    Java applet
    application/x-java-applet;version=1.4
    Java applet
    application/x-java-applet;version=1.4.1
    Java applet
    application/x-java-applet;version=1.4.2
    Java applet
    application/x-java-applet;version=1.5
    Java applet
    application/x-java-applet;version=1.6
    Java applet
    application/x-java-applet;version=1.7
    Java applet
    application/x-java-vm
    Java applet
    application/x-java-vm-npruntime
    Java applet
    QuickTime Plug-in 7.7.1
    The QuickTime Plugin allows you to view a wide variety of multimedia content in web pages. For more information, visit the QuickTime Web site. — from file “QuickTime Plugin.plugin”.
    application/sdp
    SDP stream descriptor
    sdp
    application/x-mpeg
    AMC media
    amc
    application/x-rtsp
    RTSP stream descriptor
    rtsp,rts
    application/x-sdp
    SDP stream descriptor
    sdp
    audio/3gpp
    3GPP media
    3gp,3gpp
    audio/3gpp2
    3GPP2 media
    3g2,3gp2
    audio/aac
    AAC audio
    aac,adts
    audio/ac3
    AC3 audio
    ac3
    audio/aiff
    AIFF audio
    aiff,aif,aifc,cdda
    audio/amr
    AMR audio
    amr
    audio/basic
    uLaw/AU audio
    au,snd,ulw
    audio/mid
    MIDI
    mid,midi,smf,kar
    audio/midi
    MIDI
    mid,midi,smf,kar
    audio/mp3
    MP3 audio
    mp3,swa
    audio/mp4
    MPEG-4 media
    mp4
    audio/mpeg
    MPEG audio
    mpeg,mpg,m1s,m1a,mp2,mpm,mpa,m2a,mp3,swa
    audio/mpeg3
    MP3 audio
    mp3,swa
    audio/vnd.qcelp
    QUALCOMM PureVoice audio
    qcp,qcp
    audio/wav
    WAVE audio
    wav,bwf
    audio/x-aac
    AAC audio
    aac,adts
    audio/x-ac3
    AC3 audio
    ac3
    audio/x-aiff
    AIFF audio
    aiff,aif,aifc,cdda
    audio/x-caf
    CAF audio
    caf
    audio/x-gsm
    GSM audio
    gsm
    audio/x-m4a
    AAC audio
    m4a
    audio/x-m4b
    AAC audio book
    m4b
    audio/x-m4p
    AAC audio (protected)
    m4p
    audio/x-midi
    MIDI
    mid,midi,smf,kar
    audio/x-mp3
    MP3 audio
    mp3,swa
    audio/x-mpeg
    MPEG audio
    mpeg,mpg,m1s,m1a,mp2,mpm,mpa,m2a,mp3,swa
    audio/x-mpeg3
    MP3 audio
    mp3,swa
    audio/x-wav
    WAVE audio
    wav,bwf
    image/jp2
    JPEG2000 image
    jp2
    image/jpeg2000
    JPEG2000 image
    jp2
    image/jpeg2000-image
    JPEG2000 image
    jp2
    image/pict
    PICT image
    pict,pic,pct
    image/png
    PNG image
    png
    image/tiff
    TIFF image
    tif,tiff
    image/x-bmp
    BMP image
    bmp,dib
    image/x-jpeg2000-image
    JPEG2000 image
    jp2
    image/x-macpaint
    MacPaint image
    pntg,pnt,mac
    image/x-pict
    PICT image
    pict,pic,pct
    image/x-png
    PNG image
    png
    image/x-quicktime
    QuickTime image
    qtif,qti
    image/x-sgi
    SGI image
    sgi,rgb
    image/x-targa
    TGA image
    targa,tga
    image/x-tiff
    TIFF image
    tif,tiff
    video/3gpp
    3GPP media
    3gp,3gpp
    video/3gpp2
    3GPP2 media
    3g2,3gp2
    video/avi
    Video For Windows (AVI)
    avi,vfw
    video/flc
    AutoDesk Animator (FLC)
    flc,fli,cel
    video/mp4
    MPEG-4 media
    mp4
    video/mpeg
    MPEG media
    mpeg,mpg,m1s,m1v,m1a,m75,m15,mp2,mpm,mpv,mpa
    video/msvideo
    Video For Windows (AVI)
    avi,vfw
    video/quicktime
    QuickTime Movie
    mov,qt,mqv
    video/sd-video
    SD video
    sdv
    video/x-m4v
    Video (protected)
    m4v
    video/x-mpeg
    MPEG media
    mpeg,mpg,m1s,m1v,m1a,m75,m15,mp2,mpm,mpv,mpa
    video/x-msvideo
    Video For Windows (AVI)
    avi,vfw
    SharePoint Browser Plug-in
    Microsoft Office for Mac SharePoint Browser Plug-in — from file “SharePointBrowserPlugin.plugin”.
    application/x-sharepoint
    Microsoft Office for Mac SharePoint Browser Plug-in
    Shockwave Flash
    Shockwave Flash 11.9 r900 — from file “Flash Player.plugin”.
    application/futuresplash
    FutureSplash Player
    spl
    application/x-shockwave-flash
    Shockwave Flash
    swf
    Silverlight Plug-In
    5.1.20913.0 — from file “Silverlight.plugin”.
    application/x-silverlight

Maybe you are looking for

  • Show / hide field based on text in another field

    Hi, I'm trying to make one of my fields reactive to what is the text generated in another field. At the moment I have this under calculate using custom javascript: var Mask = this.getField("Course").value; if(Mask == 'Swimming') this.getField("Code")

  • Where to find which plant has a particular factory calendor?

    Hi Where can i find that which plant has been assigned to which factory calendor? Transaction SCAL helps to display calendor if i know the calendor ID...But i want to know factory calendor for a particular plant?? Please give your comments Rgds

  • Help Regarding Table

    Hello frnds i hv to add two fields into a table but by mistakely i hv added three fields to that particular table now the problem is this when i m trying to delete the extra field it is showing me error that structure has changed and i m not able to

  • I purchased a movie and when trying to watch it iTunes always closes the program.  what am i doing wrong?

    I synced my iPod touch to iTunes and am able to watch the movie on mu ipod.  tried again in itunes and the program still closes.0

  • Sign in and EULA

    Running CC on Windows 7 – why do I need to sign into CC every time I restart my computer and constantly have to agree to the EULA? Is there a "Keep me signed in" option I am missing?