Trouble with file paths

Hi,
I'm trying to read a XML file using:
XMLDocBuilder.java
public Document getXML(String filepath) throws SAXException, IOException, ParserConfigurationException
          File myFile = new File(filepath);          
          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
          dbf.setNamespaceAware(false);
          DocumentBuilder docBuilder = dbf.newDocumentBuilder();
          Document myDoc = docBuilder.parse(myFile);
          return myDoc;
     }If I run it directly from Eclipse/Tomcat, it works fine, but if I try to run it from the browser I get the exception "java.io.FileNotFoundException: C:\Documents and Settings\daugusto\content.xml (The system couldn't find the specified file)". (The file isn't there, it's on D:\MyFiles\myProject\WebContent\content.xml)
I've tried quite some ways now and still couldn't get this to work.
How can I get it to work from a browser?

The class receives the filepath argument from a JSP page, after the user submits a form.
I'm trying to load the XML Document and return it to the JSP page so I can work with it's elements. Using the <input type="file"> component?
You don't want to retrieve the file using the java.io library.
The server normally doesn't have access to the client file system. The only exception is when you are a developer working on your local machine where the server and the client are one and the same. That is not the general case :-).
Intead use a library like the apache commons file upload to read the binary data of the file uploaded.
cheers,
evnafets

Similar Messages

  • Problem with file path in linux

    hi,
    i have problem with file path accessing in linux. my java class is accessing a abc.cvs file and and getting all data. it is working fine in windows xp. but i run this same file in linux it does not access the abc.cvs file and does not get any data.
    my project structure
    Search
    abc.cvs
    search.SearchMain
    i am sccessing this cvs file in this SearchMain class by this way file name = "abc.cvs"
    It is working fine with window but problem with linux.
    when i place this abc.cvs in a folder as "./data/abc.cvs" also working fine with windows but not in linux.
    I am new for linux.
    Please give me solution.
    Thanks in advance
    Ravi

    forgot to tell,
    then you need to export that path
    export $CLASSPATH
    code}                                                                                                                                                                               

  • Trouble with clipping paths in Photoshop CS5

    Hello everyone, I am having trouble with clipping paths in Photoshop CS5. When I start a new path both path and anchor points are not visible. working on a Layer not background 0 and a Path Layer was created.I've also noticed that Photoshop started running pretty slow. All other programs are fine. Any Ideas or suggestions? Thank You

    edtGrfx wrote:
    Hello everyone, I am having trouble with clipping paths in Photoshop CS5. When I start a new path both path and anchor points are not visible. working on a Layer not background 0 and a Path Layer was created.
    What do you mean by "a Path Layer was created"?  Path are in the path palette, there is a path in shape layers and they is a path in a vector layer mask. I have never seen a reference to a path layer before this.  When a path in the path palette is selected activate it wall also be shown in the image window.  Does not matter if there is a targeted layer or not.  Control points may or may not be displayed. Using Path tool you can select and select segments and show some or all control points, Path are editable.
    View the following image in a new tab and scale to actual pixels for a clear image this site scales image poorly.

  • How To Work With File Path in Forms

    Hi
    I have one button on form i use it to call microsoft word when i finsh work i want to save my word file then open save DIALOG box to save that file
    i want to take that path from save dialog box to text item in my form
    how can i do this ?

    If you are using Forms version 9.x or newer, you can use WebUtil to open Word on the client machine, Save the Word file, then do whatever you'd like with the path where the file was saved. If you are using an older version in client/server mode and not web, you would do something similar ony you would use OLE from within the form to call Word.
    In short, we cannot offer much information because you did not provide enough detail about what you are doing, how you are doing it and which product and platform versions you are using.
    WebUtil is included in Forms 10.1.2, so there is no need to download it. In version 9, you would need to manually download and configure it from here:
    http://www.oracle.com/technology/products/forms/htdocs/webutil/webutil.htm

  • File Attachment in a Email.... problem with file path

    Hi experts
    I am trying to implement something similar to any email program.
    A user can send email to a user along with attachments.
    I am encountering the following problems:
    1) in IE, the file path is set correctly, but in mozilla only the file name is set. (how do i get the file path in mozilla??)
    2) if i add the file as part of the body in the email, the destination user should only see only the file name and not the entire file path of the source computer.
    any help would be appreciated
    thanx
    deepak

    File on web forms is attached to the case. Go to the case in the admin and you can retrieve the file.

  • Issues with file path in java.io.File

    I am getting file path in eclipse plugin using org.eclipse.swt.widgets.FileDialog and saving the path in XML files.
    In web.xml , path is stored as below (I can't change backsladh to forwardslash or escape backslash since the value is coming from SWT FileDialog)
    <init-param>
    <param-name>filePath</param-name>
    <param-value>c:\new\demo\next\version.txt</param-value>
    </init-param>
    In my filter , i have below code in init() method but am not able to get File reference due to special characters
    String filePath = filterConfig.getInitParameter("filePath");
    // Tried filePath.replace('\\','/') --> Didnot work since \n is a single character
    File f = new File(path)

    No it does not. You need to escape file paths properly. You can check this with simple code and that the problem i am facing now
         public static void main(String[] args) {
              String path = Messages.getString("filePath"); //in messages.properties put filePath=c:\new\next\verison.txt
              System.out.println(path);
              File f = new File(path);
              System.out.println(f.exists());
         }

  • Problem launching Firefox from Windows with file path that contains space characters in the html file's file name

    We have a software application that programmatically launches the default web browser using the Windows shell execute function ("ShellExecuteA" in the "shell32.dll" library of the Windows API) along with a file path for a saved local html file that is to be displayed. In the case that FireFox is the default browser and the file path for the html file contains any space characters in the html file's file name, Firefox (in this case v7.01) will display an error message "File not Found..." and then will also proceed to open tabs for each of the individual words in the file name, launching as the URL path, each individual word appended to ".com".
    In the following example, the path "C:\KSSecOfState\Forms\Kansas Secretary of State - Filings and Forms.htm" when launched programmatically, resulted in the error message "File not Found...Firefox can't find the file at /C:/KSSecOfState/Forms/Kansas." and opened up browser windows for "http://www.secretary.com/", "http://www.of.com/", "http://www.state.com/", "http://www.and.com/", and attempted to launch "http://forms.htm". If the same file (renamed) is launched using the path string "C:\KSSecOfState\Forms\KansasSecretaryOfState-FilingsAndForms.htm" the file opens up correctly in Firefox. Clearly the presence of spaces in the file name is causing the problem.
    I should also note that either path (with or without space characters) works properly if pasted directly into the Firefox URL path menu bar for a live instance of Firefox. The test path strings I used were:
    C:\KSSecOfState\Forms\KansasSecretaryOfState-FilingsAndForms.htm
    C:\KSSecOfState\Forms\Kansas Secretary of State - Filings and Forms.htm
    Does anyone know anything about this problem or how to work around it (other than the obvious answer of taking the spaces out of the file name which is not possible for this application). It seems the problem is specific to Firefox. IE works properly if launched programmatically with spaces in the file name passed to it. I haven't tested other browsers yet.
    Thanks!

    If starting from ShellExecute works the same as starting from the command line then there are two options:<br>
    Put everything inside double quotes<br>
    '''C:\Program Files\Mozilla Firefox\>'''firefox.exe '''"c:\test\svg test.htm"'''<br>
    Convert to a valid url with file:// protocol and percentage-escaping the space<br>
    '''C:\Program Files\Mozilla Firefox\>'''firefox.exe '''file://c:\test\svg%20test.htm'''<br>

  • Problems with file paths in ApplescriptObjC

    Hi
    I am having a problem with trying to Open/Read/Write/Close text files in ApplescriptObjC. The following piece of script works in Applescript but when I try to incorporate in ASOC via Xcode I get the following error "Can’t make current application into type «class fsrf»"  and I have no idea what that means!
    I've tried using POSIX paths but still doesn't work. As usual, any help gratefully received.
    I am using the Control Record to hold the last reference number used so when I add another row to a spreadsheet it will generate the next unique reference.
    set filePath "Macintosh HD:Users:Ours:Documents:Cats Protection:Control Record.txt"
    set fileReference to open for access (file filePath) with write permission
    set lastNumber to read alias filePath -- read all data
    set nextNumber to (text -1 thru -2) of lastNumber as integer -- extract last number
    set nextNumber to (nextNumber + 1) -- increment number
    set nextNumber to text (2 * -1) thru -1 of ("0" & nextNumber) -- add leading zero
    write nextNumber to fileReference starting at 9 -- update next number
    close access fileReference

    «class fsrf» is a file system reference. Long story, but cocoa changed the preferred way to handle file references (in 10.6, I think) and sometimes applescript trips over the difference.
    try changing the first three lines like so:
    set filePath to "/Users/Ours/Documents/Cats Protection/Control Record.txt"
    set fileReference to open for access filePath with write permission
    set lastNumber to read fileReference -- read all data
    Cocoa is generally happier with posix paths, open for access shouldn't need the file keyword, and reading from the file reference (rather than specifying the file again) is cleaner.

  • Bug with file path autocompletion in a sub folder

    Hi,
    I've just update to Mavericks and re-install Edgecode. And now, it's very strange the autocompletion of a file path in a subfolder is absolute...
    i.e.
    In a a style.css file inside a CSS folder, when I write : background-image : url(../ the autocompletion find something like this "Volume/user/myname/myfolder/img" etc. instead of "../img" and it doesn't list the file inside the folder...
    Anyone have the same problem ?
    Thx

    Thanks for reporting bugs. This has been fixed for the next release of Edge Code CC.
    Randy

  • Stuck with File Path

    I am writing a very simple script that exports an image's cutline for my newsroom, i am getting stuck with the having it write the file to the correct path. When I run script as below it works, writing the file to my documents:
    function writeCutline () {
                    // Linefeed shizzle
                if ($.os.search(/windows/i) != -1)
                    fileLineFeed = "windows";
                else
                    fileLineFeed = "macintosh";
        var fileName = app.activeDocument.name
        var MetaInfo = app.activeDocument.info;
        MetaInfo = MetaInfo.caption;
        var fileOut = new File(Folder.myDocuments + '/'+ fileName.substring(0,fileName.length-4)+ '.txt');
        fileOut.linefeed = fileLineFeed;
        fileOut.open("w", "TEXT", "????");
        fileOut.writeln(MetaInfo);
        fileOut.close();
    writeCutline();
    What I want it to do is:
    var fileOut = new File( '/c/cutlines/'+ fileName.substring(0,fileName.length-4)+ '.txt');
    but this does not work. What do I have to do different?

    Thanks for the help guys. I wasn't actually putting the files on C: it was actually going to a mapped network drive and for some reason last night the server was working incorrectly and that is where my problems where coming from. But that raises my next question, is there anyway to address the path with mapping the drive, so it would be a refence to the server. If i was browsing the path it would be TARHSHARE/PHOTOS/photos/DailyATS/Cutlines. With PHOTOS mapped to drive P the path is P:/Photos/Daily/ATS/Cutlines. So what I want to do is get it work without mapping the drive, so the script will work on all of the photographers accounts without mapping the drive.

  • BUG with File Path Browse Button

    Hi,
    I am using LabVIEW 2011 SP1 running in Windows 7.
    I have a Path Control with the Browse Button visible on a front panel.
    In the browse options, I have selected ‘Allow selection of files in LLBs and packed project libraries’
    For the Selection Modes, I have Files or Folders and Existing selected.
    When this VI is run in the LabVIEW Development System (2011 SP1) the Browse Button works as expected and displays the top level Vis in the Packed Library.
    When this VI is run in the LabVIEW Development System (2011 SP1) the Browse Button works as expected and displays the top level Vis in the Packed Library and returns the full path if the selected VI when the OK button is pressed.
    I have built the Main VI into an executeable and when this is run the browse button doesn’t display the dialog window when selecting the .LVLIBP file to browse into.
    Is this some sort of bug in LabVIEW 2011 SP1?
    If it is a bug, has it been fixed in a later release of LabVIEW?
    I have attached a small example to demonstrate the problem.
    Regards
    Ray Farmer
    Attachments:
    Test package.zip ‏542 KB

    Works in the dev environment.  No dialog at all in an executable.  Test done with LabVIEW 2014, Windows 7.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Print list showing graphics used with file paths

    My company is in the process of remapping the graphics on a shared network and I need to go through and make a list of all grphics used in publications along with their filename/path. Hoping there is some plug-in or feature that I can use to create a report that lists this information vs. looking at the options in the links manager and writing things down by hand. Any suggestions? I see the information in a .ps (postscript file) however it's cluttered with everything else. Can I somehow use the ps file and extract only the directory extenstions and filenames/paths.

    FYI I'm working in Pagemaker 6.5 on Windows XP. I can get a report that lists the graphics if I package for Service Provider - unfortunately it doesn't list where the original graphics were located simply the directory it was saved to for teh service provider.

  • Trouble with database path (DSC)

    Hello,
    I use DSC and LabVIEW 2009 in my application, and I created programmatically Shared variables, which have to be logged in Citadel database. For that, I create a database with Create Database VI with a specified path , and afterwards I use Configure Process Log State VI to bind values from my shared variables to the database.
    The problem I have is the following: the database is created as expected in the correct path ( I have a folder created, with some .cdih , .cdin file), but after, on MAX, when I want to see trendings, i notice my database appears under Citadel 5, but nothing is inside. Actually, all my shared var are log in Default_database, the default database of DSC...Moreover, I have this event in Event Viewer (see attached image), which says
     I don't understand why i have such error...The problem is the final purpose is to create a standalone app with installer, and clients want to choose where they store their data...
    thanks for your help
    Antoine

    Hi Antoine,
    could you please post you code and your LabVIEW Version?
    Kind regards
    Carsten

  • Trouble with clipping paths and expanding

    Hey y'all. Okay, so I have a Illustrator element that uses a clipping path.
    Even after I run "Expand Appearance" on it, it's not trimming the art to the bounds of the path.
    It's making for difficult to position correctly when copying into Photoshop as a Smart Vector or Shape Layer:
    And it isn't correct in After Effects either.

    What you are describing is just another example of the very common need to trim artwork (including filled, unfilled, open, and/or closed paths) without wrecking its already-applied Attributes, Appearances.
    As has been discussed many many times here, Illustrator simply does not provide that basic functionality...neither by its horribly-designed cutting tools nor through its problematic and caveat-riddled Pathfinders. Expanding a Clipping Path doesn't serve as a workaround for this long-missing functionality; nor does flattening transparency. You can't do it without resorting to the workarounds you've already tried or others that will no doubt be suggested.
    Once again:
    NONE of Illustrator's cutting tools (Knife, Scissor) can cut across artwork that includes multiple open, unfilled paths. Open unfilled paths are ignored by the Knife cut. The Scissor cannot cut across multiple paths at once.
    Illustrator's recently-added, very poorly implemented Eraser tool comes nearest to the needed functionality. It can at least cut multiple unfilled open paths without their becoming converted to unstroked, closed fills. But it unpredictably alters the shapes of remaining portions and has no means by which to accurately control a cutting shape other than rectangular.
    This is a prime example (there are others) of how Illustrator confuses and clutters the interface with multiple under-powered tools designed for similar functions, none of which measure up to a single tool properly designed for the same purposes in most other programs.
    Pathfinders are riddled with ridiculous caveats. Those which come close to providing the needed functionality are incapable of ommitting the unwanted deadwood and/or wreck strokes by outlining them.
    Illustrator needs a feature that allows any given path to be employed as either a selection marquee or a cutting path. And the cutting operation needs to act as expected regarding strokes as well as fills--as common in any other drawing program that does provide the long-missing functionality (most do; Illustator never has).
    JET

  • ReplaceAll with file-path

    Hello,
    I get a filename from a textfield the user fills in.
    Then I want to do following:
    String in = "....kdfbkhsdbfkbfe #FILENAME# sdfsdkjfhskjdf...";
    String out = in.replaceAll("#FILENAME#",textField.getText());
    Problem: When user fills in something like E:\dir\temp\file then in out there is E:dirtempfile
    ??

    This is because the replacement string is not treated as a plain string. The replacement string may have references to the matching regular expression by using $number. \ is used to escape the $-sign when you want to use it as such.
    [url http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Matcher.html#replaceAll(java.lang.String)]http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Matcher.html#replaceAll(java.lang.String)
        "abcde".replaceAll("[bd]", "<$0>") = a<b>c<d>e
       "abcde".replaceAll("[bd]", "<\\$0>") = a<$0>c<$0>e
       "abcde".replaceAll("[bd]", "\\\\") = a\c\eSo you need to insert slashes in front of each \ and $. This can be done with    textField.getText().replaceAll("[\\\\$]", "\\\\$0");

Maybe you are looking for