How to get the complete path of the file that is selected using FormFile

i m working on struts..
i hv used FormFile like
<html:file property="xsdpath" value="Browse" />
need to get the whole path that i will select using browse button
for example d:\foldername\filename.java
but FormFile Api has a method getFileName(); which returns the filename, for getting the absolute path wat has to be done.
please reply bak soon
thanks in advance

here i use formfile <html:file> just to allow the
user to select a xml file .
so i need to get the whole path of the selectedfile
to parse the xml file.No you dont.
You would definitely benefit from further reading on
file upload.
<html:file> tag renders an HTML <input> element of
type file.
When a user uploads a file, this file is sent as a
stream of data, which a program (jsp/servlet) on the
server, reads and stores the data back in the form
of a file on the server.
Any server program that needs to parse the file,
should do so on the file stored on the server.
There's no point in knowing the absolute path of the
file on the client machine. If a server program can
parse a file on the client machine, why upload the
file in first case ? Get the drift ?
i also want to show my user the path he hadselected.
If you have such a requirement, then yes.
But it sounds weird to me. If you see my response
above, you will realize that the server has a copy of
the client's file uploaded and then parsed. What if
the client has changed his file after upload ?
cheers,
ram.I also have a requirement to get the whole filepath of the file selected and place this information into a table. From FormFile I can only retreive the absolute filename
Any suggestions would be helpful.
Thanks, dam

Similar Messages

  • How to display all the files that are selected using JFile chooser

    please hepl me i m posting my code here.
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.zip.Deflater;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    public class browser extends JFrame
    String curDir;
    JLabel statusbar;
    public browser()
    super("File Chooser Test Frame");
    setSize(1050,600);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    curDir = System.getProperty("user.dir") + File.separator;
    statusbar = new JLabel("Output of your button choice goes here!");
    Container c = getContentPane();
    c.setLayout( null );
    JButton openButton = new JButton("Browse file");
    JButton dirButton = new JButton("Pick Dir");
    JButton resetButton = new JButton("Reset");
    JButton submitButton = new JButton("Submit");
    final JTextArea tf = new JTextArea(100,50);
    final JList l1 = new JList("list");
    tf.setEditable(true);
    // add the open FILE chooser
    openButton.addActionListener(new ActionListener()
         public void actionPerformed(ActionEvent ae)
         JFileChooser chooser = new JFileChooser(curDir);
         chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
         chooser.setMultiSelectionEnabled(true);
    //Java 1.6 can use FileNameExtensionFilter class
    // FileFilter filter=new FileNameExtensionFilter("HTML file","htm","html")
    // chooser.addChoosableFileFilter(filter);
    //Prior versions must use external extension of FileFilter class (ie ExtFilter)
    //ExtFilter requires separate compile to enable choosable selection
         String[] html = new String[] {"htm","html","xhtml"};
         int option = chooser.showOpenDialog(browser.this);
         if (option == JFileChooser.APPROVE_OPTION)
         File[] sf = chooser.getSelectedFiles();
         String filelist = "nothing";
         try
         if (sf.length > 0) filelist = sf[0].getCanonicalPath();
         for (int i = 1; i < sf.length; i++)
         {filelist += ", " + sf[i].getCanonicalPath();
    tf.setText("our choices" + filelist);
         catch (IOException evt) {System.out.println("Exception: "+evt);}
    statusbar.setText("Your choices: " + filelist );
    // String[] text = new String[100];
    //getChars(0,100,text[],0);
    l1.setText("your choices \n" + filelist);
         else {statusbar.setText("You cancelled!");}
    // add the open DIRECTORY chooser
    dirButton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    JFileChooser chooser = new JFileChooser(curDir);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
         chooser.setMultiSelectionEnabled(false);
    int option = chooser.showOpenDialog(browser.this);
    if (option == JFileChooser.APPROVE_OPTION)
    File[] sf = chooser.getSelectedFiles();
    String filelist = "nothing";
    try
    if (sf.length > 0) filelist = sf[0].getCanonicalPath();
    for (int i = 1; i < sf.length; i++)
              {filelist += ", " + sf[i].getCanonicalPath();}
         catch (IOException evt) {System.out.println("Exception: "+evt);}
    statusbar.setText("You chose " + filelist);
         else {statusbar.setText("You cancelled!");}
    System.out.println("Example of ZIP file creation.");
    // Specify files to be zipped
    String[] filesToZip = new String[1];
    filesToZip[0] = "filelist";
    byte[] buffer = new byte[18024];
    // Specify zip file name
    String zipFileName = "example.zip";
    try {
    ZipOutputStream out =
    new ZipOutputStream(new FileOutputStream(zipFileName));
    // Set the compression ratio
    out.setLevel(Deflater.DEFAULT_COMPRESSION);
    // iterate through the array of files, adding each to the zip file
    for (int i = 0; i < filesToZip.length; i++) {
    System.out.println(i);
    // Associate a file input stream for the current file
    FileInputStream in = new FileInputStream(filesToZip);
    // Add ZIP entry to output stream.
    out.putNextEntry(new ZipEntry(filesToZip[i]));
    // Transfer bytes from the current file to the ZIP file
    //out.write(buffer, 0, in.read(buffer));
    int len;
    while ((len = in.read(buffer)) > 0)
    out.write(buffer, 0, len);
    // Close the current entry
    out.closeEntry();
    // Close the current file input stream
    in.close();
    // Close the ZipOutPutStream
    out.close();
    catch (IllegalArgumentException iae) {
    iae.printStackTrace();
    catch (FileNotFoundException fnfe) {
    fnfe.printStackTrace();
    catch (IOException ioe)
    ioe.printStackTrace();
    c.add(openButton);
    c.add(dirButton);
    c.add(statusbar);
    c.add(resetButton);
    c.add(submitButton);
    //c.add(tf);
    c.add(l1);
    Insets insets = c.getInsets();
    Dimension size = openButton.getPreferredSize();
    openButton.setBounds(745 + insets.left,115 + insets.top, size.width, size.height);
    size = dirButton.getPreferredSize();
    dirButton.setBounds(755 + insets.left,165 + insets.top, size.width, size.height);
    size = statusbar.getPreferredSize();
    statusbar.setBounds(755 + insets.left,215 + insets.top, size.width, size.height);
    size = resetButton.getPreferredSize();
    resetButton.setBounds(755 + insets.left,265 + insets.top, size.width, size.height);
    size = submitButton.getPreferredSize();
    submitButton.setBounds(755 + insets.left,465 + insets.top, size.width, size.height);
    size = tf.getPreferredSize();
    tf.setBounds(25 + insets.left,5 + insets.top, size.width + 150, size.height + 430);
    size = l1.getPreferredSize();
    l1.setBounds(25 + insets.left,5 + insets.top, size.width + 150, size.height + 430);
    setSize(1000,800);
    setVisible(true);
    public static void main(String[] args)
    new browser();

    Start by defining "display". Then continue by reading this:
    http://forum.java.sun.com/help.jspa?sec=formatting

  • How to get the file size (in bytes) for all files in a directory?

    How to get the file size (in bytes) for all files in a directory?
    The following code does not work. isFile() does NOT recognize files as files but only as directories. Why?
    Furthermore the size is not retrieved correctly.
    How do I have to code it otherwise? Is there a way of not converting f-to-string-to-File again but iterate over all file objects instead?
    Thank you
    Peter
    java.io.File f = new java.io.File("D:/todo/");
    files = f.list();
    for (int i = 0; i < files.length; i++) {
    System.out.println("fn=" + files);
    if (new File(files[i]).isFile())
         System.out.println("file[" + i + "]=" + files[i] + " size=" + (new File(files[i])).length() ); }

    pstein wrote:
    ...The following code does not work. Work?! It does not even compile! Please consider posting code in the form of an SSCCE in future.
    Here is an SSCCE.
    import java.io.File;
    class ListFiles {
        public static void main(String[] args) {
            java.io.File f = new java.io.File("/media/disk");
            // provides only the file names, not the path/name!
            //String[] files = f.list();
            File[] files = f.listFiles();
            for (int i = 0; i < files.length; i++) {
                System.out.println("fn=" + files);
    if (files[i].isFile()) {
    System.out.println(
    "file[" +
    i +
    "]=" +
    files[i] +
    " size=" +
    (files[i]).length() );
    }Edit 1:
    Also, in future, when posting code, code snippets, HTML/XML or input/output, please use the code tags to retain the indentation and formatting.   To do that, select the code and click the CODE button seen on the Plain Text tab of the message posting form.  It took me longer to clean up that code and turn it into an SSCCE, than it took to +solve the problem.+
    Edited by: AndrewThompson64 on Jul 21, 2009 8:47 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to get the values from html:select? tag..?

    i tried with this, but its not working...
    <html:select styleClass="text" name="querydefs" property="shortcut"
                 onchange="retrieveOptions()" styleId="firstBox" indexed="true">
    <html:options collection="advanced.choices" property="shortcut" labelProperty="label" />
    </html:select>
                        <td align="left" class="rowcolor1">
                        <script language="javascript" type="text/javascript">
                              function retrieveOptions(){
                             var sel = document.querydefs.options;
                             var selectedOption = sel[sel.selectedIndex].value;
                             document.write(selectedOption);
                           </script>

    <td align="left" class="rowcolor1">
                        <script language="javascript" type="text/javascript">
                              function retrieveOptions(){
                             var sel = document.querydefs.options;
                             var selectedOption = sel[sel.selectedIndex].value;
                             document.write(selectedOption);
                           </script>This java script is not working at all..its not printing anything in document.write();
    This is code..
    <td class="rowcolor1" width="20%">
    <html:select styleClass="text" name="querydefs" property="shortcut"
                             onchange="retrieveSecondOptions()" styleId="firstBox"
                             indexed="true">
                             <html:options collection="advanced.choices" property="shortcut"
                                  labelProperty="label"  />
                        </html:select>i tried with this also. but no use..i'm not the getting the seleced option...
    function retrieveOptions(){
    firstBox = document.getElementById('firstBox');
                             if(firstBox.selectedIndex==0){
          return;
        selectedOption = firstBox.options[firstBox.selectedIndex].value;
    }actually , how to get the values from <html:select> ...?
    my idea is to know which value is selected from the combo box(<html:select> ) if that value is equal some string i have enable a hyperlink to open a popup window

  • How to get the files in presentation server while uploading?

    how to get the files in presentation server while uploading?
    give me the function module name

    Hi,
    PARAMETERS:  P_FILE LIKE RLGRAP-FILENAME DEFAULT C_PRES.  "Prsnt Srvr
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      CALL FUNCTION 'WS_FILENAME_GET'
        EXPORTING
          DEF_PATH         = P_FILE
          MASK             = ',..'
          MODE             = '0 '
          TITLE            = 'Choose File'
        IMPORTING
          FILENAME         = P_FILE
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_ERROR  = 4
          OTHERS           = 5.

  • [CS3][JS] How to get the file type of current document

    Hi,
    How to get the file type of current opening document (e.g., tif, jpeg, png) using JavaScript with Photoshop CS3.
    I am using file object the open the files one by one in the folder (the files sometimes don't have the extensions).
    If the current document is in tiff format then I need to convert to 8-bit, if its an Jpg image then needs to ignore the file.
    Regards,
    Karthik

    Do you really need to know the file type? What about just checking the bit depth?
    var doc = activeDocument;
    if (doc.bitsPerChannel != BitsPerChannelType.EIGHT) {//Not 8 bit
    doc.bitsPerChannel = BitsPerChannelType.EIGHT;
    //do your save etc
    }else{
        //Ignore

  • HT1727 My old computer died on me with no warning signs. I didn't know or need to copy my music to another computer. I would like to know how to get the music that I bought onto my new computer without having to buy it all again.

    My old computer died on me with no warning signs. I didn't know or need to copy my music to another computer. I would like to know how to get the music that I bought onto my new computer without having to buy it all again. I just want to be able to get all of my music that I bought on itunes onto my computer. Right now the money ive spent is just gone and I have no music to show for it.

    Go to the iTunes Store and select "Purchased" from the Quick Links side bar on the right. Go through all the tabs to download again for free

  • How to get the form name which is used in standard tcode like me23n in sap

    how to get the form name which is used in standard tcode like me23n in sap
    Moderator message: four out of four threads locked, please read and understand the following before posting further:
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    [Asking Good Questions in the Forums to get Good Answers|Asking Good Questions in the SCN Discussion Spaces will help you get Good Answers]
    Edited by: Thomas Zloch on Nov 18, 2011 1:32 PM

    how to get the form name which is used in standard tcode like me23n in sap
    Moderator message: four out of four threads locked, please read and understand the following before posting further:
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    [Asking Good Questions in the Forums to get Good Answers|Asking Good Questions in the SCN Discussion Spaces will help you get Good Answers]
    Edited by: Thomas Zloch on Nov 18, 2011 1:32 PM

  • I do not know how to get the music that I buy on itunes, on my mac, onto an ipod. I have already authorized my computer and "downloaded" my music, but that did not do anything. Please I really need to know how to do this on my own but I am stuck.Thank you

    I do not know how to get the music that I buy on itunes, on my mac, onto an ipod. I have already authorized my computer and "downloaded" my music, but that did not do anything, or provid the results that I was expecting, at least. Please, I really need to know how to do this on my own but I do not know what to do.Thank you in advance to anyone that is answering this question that I know most everyone but me knows how to accomplish. thanks!!!

    In iTunes go to the Help menu in the upper menu bar.  Then click on iTunes Help. Then on Sync your iPod, iPhone or iPad and follow the instructions.

  • I use iPhoto and want to know how to get the 'key photo' i select on my MacBook Pro to be the one that gets used on my iPhone when i sync them. Any ideas? also, i want the events to appear in the order i choose on my MacBook too

    I use iPhoto and want to know how to get the 'key photo' i select on my McBook Pro to be the same one that gets used on my iPhone 5s when i sync. i also want the events to appear on the iPhone in the same order i have them on my macbook. any ideas there too?

    Killerfinch wrote:
    My new yahoo account nestles comfortably in iCloud on the mine iPad.
    No, your Yahoo account is not in iCloud (which only handles iCloud mail), it is in Yahoo, and the Yahoo mail account is on your iPad.
    But the MacBook Pro will have none of it! I write this question now as I fear that I will be totally demented very soon and unable to formulate my thoughts clearly!
    Get the correct settings for your account from Yahoo and set it up manually.
    By the way, I also find the "password" issue problematical. It seems Apple want my Apple password rather than my eMail password. All very confusing.
    That would depend on what you are trying to do.

  • HT5035 I will like to know how to get the money that i have in my  Itunes acc to get it off and buy a cd with it

    I will like to know how to get the money that i have in my itunes acc how to used it up to buy a cd with it

    LatachaM_VZW wrote:
    If the incorrect PIN code is entered too many times, a PIN Unlock Key must be obtained from Verizon Wireless at 908-559-4899 if you are outside of the United States and 800-922-0204 or *611(send) from your mobile number inside the United States..
    The SIM PIN option is only available when the handset is in GSM / UMTS mode. Refer to Network Mode Setting for further assistance.
    Thank you, LatachaM_VZW
    Are you talking about the PUK code (when the PIN for the SIM has been wrong too many times)?  The OP is talking about network unlock, and is using a foreign SIM.   Global Services certainly wouldn't have the unlock code for a SIM that isn't theirs.
    I have heard that if you do enter the incorrect network unlock code too many times, the phone becomes permanently locked (i..e cannot be unlocked even with a valid unlock code) but not everyone agrees that this is true for all phones.
    Jax's post above really says it all, you will need to search the web for a service that will unlock this Motorola phone.  In doing so, you might find a number of threads that say the Global has to be activated in the US before an unlock code will work.  Others were able to unlock without this. 

  • How to find the file that delete from time capsule?

    How to find the file that delete from time capsule?

    I mean I saved JPEG file in Time capsule and unfortunately delete the file. Can I get it back
    IF.... .no other backups have occured since you deleted the file, you might be able to retrieve it using an application like Disk Warrior. It's about $100 as I recall, and there are no guarantees that it will work.
    DiskWarrior 4 - The Disk Utility for Mac  Disk Repair, Mac Directory ...
    Any of the free or low priced utilities that you might see or try will not be able to retrieve a deleted file from a Time Capsule.
    If any backups have occured since you deleted the file, the deleted file has almost certainly been overwritten. No way to retrieve it in that case.

  • Cannot install Mavks. Get the message that HD is used for Time Machine B/U. Not true. Also Time Machine is turned off.

    Cannot install Mavks. Get the message that HD is used for Time Machine B/U. Not true. Also Time Machine is turned off. Running OS 10.8.5.

    That message appears when there's a "Backups.backupdb" folder in the root level of the OS X volume. This folder is used by Time Machine to store backups, being this the reason why the OS X Mavericks installer detects the OS X partition as used by Time Machine.
    To delete it, open a Finder window, select the Go menu (on the menu bar) > Go to Folder, and type:
    Then, delete "Backups.backupdb" and empty the Trash. Finally, open the OS X Mavericks installer in /Applications and follow the steps. Make sure you have got a backup of your files before upgrading and check that your apps are compatible > http://www.roaringapps.com

  • How to get folder(directory path only not file path) from local file system

    Hi Firends,
    How to get folder(directory path only not file path) from local file system , whenevr i will click on browse button.
    Please give reply for this one , if anybody knows.
    Thanks,
    Anderson.

    Hi Anderson,
    if you're using flash.filesystem.FileReference - then it is run in black box - except of filename, size and creation data (and few other properties available after some operation succeeded). This is part of security features in Flash runtime (described in header section):
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference .html
    This for example implies that user can download a content to local machine - but that content cannot be loaded back into Flash runtime. For this you would need either Air runtime flash.filesystem.File:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.h tml
    (so you would created Air runtime based application: desktop or mobile but not web, even as standalone project) or you would need one of 3rd party tools that add file access/file information features to standard Flash runtime applications converted to standalone native applications.
    hth,
    kind regards,
    Peter

  • My 2008 Macbook OS X 10.5.8 keeps getting a black box appearing around files that are selected.

    My 2008 Macbook OS X 10.5.8 keeps getting a black box appearing around files that are selected.  The volume keys are also making wigits come up and there are duplicates of "restart" and "shut down" for some reason in that apple menu.... What's going on?

    Turn off VoiceOver in the Universal Access or Accessibility pane of System Preferences.
    (82298)

Maybe you are looking for

  • Mapping to disk on Airport Extreme's USB port from G5 over Ethernet

    I just set up my Airport Extreme network, with multiple machines (Windows XP, Vista, Mac G5, iPad and iPod Touch) sharing the internet connection via both Ethernet and WiFi without any problem. My XP and Vista machines are connected via WiFi, and I w

  • Setting the charset from an adapter module

    Hi folks, I'm trying to set the charset encoding of a payload using an adapter module (I know there is a TextCodepageConverterBean, but I want to set the charset for a message that hasn't one yet). The problem is probably more clear using an example.

  • ITunes and PC with Windows 7 will not recognize my iPod....

    however iPod still works fine on an XP machine.  Our iPad is also working fine on the Windows 7 machine, including in iTunes.  The Windows 7 machine says the disk needs to be reformatted whenever I plugin the iPod. I have tried all of the possible fi

  • APO integration problem

    Hello When ECC to APO transfer Material Master. there can transfer "X-plant matl status" in Basic data1 or "Plant-sp.matl status" in MRP1 View? and if it's feasible, which i can find? Thanks

  • How to save contents in paintbox to .jpeg or any image file using Director?

    I'm having difficulty in our System using Director (THESIS) because one of the compilation we had is to save the drawings in the paintbox into an image file (.jpeg, .bmp, .png, etc). Is there someone who can help me? Please I really need to learn it