Java in JSP page can't find local file

Hi. I am very new to JSP development. I am having a strange issue. When I try to access a file within the same directory as my JSP file I get a FileNotFoundException thrown. Although, I can link the file using HTML so I know it is there in the proper directory.
<%
String line;
int i = 0;
try {
     File file  = new File("test1.csv");
     Scanner in = new Scanner(file);
     while (in.hasNextLine()) {
          line = in.nextLine();
          String strArray[] = line.split(",");
          for(int j = 0; j < strArray.length; ++j) {
               out.print((i != 0) ? (" " + strArray[j] + " ") : (" <b>" + strArray[j] + "</b> "));
          out.println("<br>");
          i++;
catch(IOException e) {
      out.print(e);
%>Anyone know how I can get the JSP to read the file?

java.io.File understands disk file system paths only, not web paths. Also, using absolute paths in java.io stuff is preferred above relative paths, because the current working directory may differ per environment.
In case of a webapplication you can use ServletContext#getRealPath() to convert a web path to an absolute disk file system path which you can use further in the usual java.io stuff.

Similar Messages

  • Where can I find locale file for hu_Hu?

    Hi,
    I have to develop some page in Hungarian but my original flex 4.5 doesn't have the necessary files.
    Here the error when i set "-locale hu_HU" in in flex compiler page :
    Description
    Resource
    Path
    Location
    Type
    unable to open 'C:\Program Files\Adobe\Adobe Flash Builder 4.5\sdks\4.5.1\frameworks\locale\hu_HU'
    MyProject
    Unknown
    Flex Problem
    Could someone tell me where I can find the missing files for the Hungarian language?
    Is my approach correct or I need to do something else?
    Thanks
    Andrea

    dial the customer-service number~

  • My home page is google and it works but when I open a new tab it displays an error message :Firefox can't find the file at chrome://quick_start/content/index.ht

    I've made sure a dozen times that my home page is set correctly, and when I hit the home button next to the search bar it works and takes me right to google BUT whenever i open a new tab i get the error that my page cannot load and the web url that it keeps trying to remember is in the error message:
    Firefox can't find the file at chrome://quick_start/content/index.html.
    of course the last dot is not the url anymore but the end of the sentence for the error message, but i don't ever use chrome ever on my laptop only my cell so what is going on????? help fix god please!!!!!!

    Do you have the FastStart extension?
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem.
    *Switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance
    *Do NOT click the Reset button on the Safe Mode start window
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • My main blog page can't find its entry pages

    When I make iWeb blog entry pages, the main blog page can't find them. It says "Error. The file cannot be found." (even if I just use the placeholder "Blue bird day" page without changing it!) I'm dragging my image onto the placeholder image on the (Modern) Blog entry page but the main Blog pag can't find it or even the placeholder image on an unmodified new blog entry page. I am publishing to a file and ftp-ing it up to my ISP but I get the "file cannot be found" message even on my own hard drive before uploading. What's wrong?
    The blog page of my site is:
    http://www.christopherrauschenberg.com/Site/Blog/Blog.html
    G5   Mac OS X (10.4.6)  

    Well, not sure of a complete solution for you, but I have found a specific problem.
    From the main blog page. . . the link it gives for New York is
    http://www.christopherrauschenberg.com/Site/Blog/429B84A8-BD4B-4B30-8A66-017811D F742E.html
    However, in checking the directory, looks like that is labeled instead as
    http://www.christopherrauschenberg.com/Site/Blog/429B84A8-BD4B-4B30-_124C76.html
    That would explain why it couldn't be found.
    A little further checking or your root directory shows similar mismatches between various page index files and the folders containing data.
    Have you published and uploaded portions at a time? Is ossible after changes we made that all changes were not published.
    It might be best to clean out the FTP folder, republish your whole site from iWeb to a folder on your computer and re-FTP it to your site (making sure to enter correct url of your site on the publish screen as well).
    (if you think I helped in any way, I'd appreciate it if you could mark my reply as either "solved" or "helpful" using the little buttons in the title bar of the reply. Manythanx! )
    Good luck!

  • TS4036 Can't find existed files at numbers and pages apps

    Hello! I wake up today, and i can't find any file at my iPadmini at numbers and pages apps. But yesterday they were existed. Please back my files .Best regards Dmitry Kartashov..

    Try looking for your files with Spotlight Search
    1. From any Home screen page of iPad, drag your finger down anywhere on the center of Home screen.
    2. Spotlight search will now appear and you can search for apps, texts, or any other content you'd like just as you did on previous versions of iOS.

  • Since downloading firefoz 4, everytime I make a browser search I get a second page with :"Firefox can't find the file at jar:file://how can I solve the problem. Kindly reply to :ramses1@videotron.ca

    Question
    firefox 4, when I make a browser search I get a second page:"Firefox can't find the file at jar:file:///D:/Program Files/Mozilla Firefox/omni.jar!/chrome/browser/content/browser/<url></url>", how can I solve the problem.

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]

  • When searching, I get this message: Firefox can't find the file at jar:file:///C:/Program Files (x86)/Mozilla Firefox/omni.jar!/chrome/en-US/locale/browser-region/region.propertiesproblems.

    when I enter a word in the search window (the one with the curved arrow at the end), I get this message:
    Firefox can't find the file at jar:file:///C:/Program Files (x86)/Mozilla Firefox/omni.jar!/chrome/en-US/locale/browser-region/region.propertiesproblems.

    Try the Firefox SafeMode to see how it works there. <br />
    ''A troubleshooting mode, which disables most Add-ons.'' <br />
    ''(If you're not using it, switch to the Default Theme.)''
    * You can open the Firefox 4/5/6/7 SafeMode by holding the '''Shft''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item, click on '''Restart with Add-ons Disabled...''' while Firefox is running. <br />
    ''Don't select anything right now, just use "Continue in SafeMode."''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shft key) to open it again.''
    If it is good in the Firefox SafeMode, your problem is probably caused by an extension, and you need to figure out which one. <br />
    http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes

  • Trouble getting page so reinstalled, get this message-Firefox can't find the file at place:sort=8&maxResults=10. How can I reinstall?

    I was trying to customize my page but then Firefox became completely unavailable. It only gives this message, along with 'trouble finding page': Firefox can't find the file at place:sort=8&maxResults=10. I tried rebooting and then reinstalling Firefox but the same message recurs. I can only get to the web now by using Internet Explorer which I don't like. But I may have to switch to it anyway.

    That is a place query (smart bookmark) for Recently Visited Location and not a normal bookmark.
    *https://developer.mozilla.org/Places_query_URIs
    Did you create this query yourself?
    You can check the home page setting:
    *Tools > Options > General > Startup: Home page
    Firefox supports multiple home pages separated by '|' (pipe) symbols.
    *https://support.mozilla.org/kb/How+to+set+the+home+page
    You can check for problems with the <b>places.sqlite</b> database file in the Firefox profile folder.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.org/kb/Bookmarks+not+saved#w_fix-the-bookmarks-file
    *Places Maintenance: https://addons.mozilla.org/firefox/addon/places-maintenance/

  • I upgraded to Firefox 8. Now my home page says this: "Firefox can't find the file at jar:file:///C:/Program Files (x86)/Mozilla Firefox/omni.jar!/browserconfig.properties.

    This is what it says on my screen when I open Firefox:
    Firefox can't find the file at jar:file:///C:/Program Files (x86)/Mozilla Firefox/omni.jar!/browserconfig.properties.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Tocat/JSP/The system cannot find the file specified

    Hi,
    I am trying to read a file(test.txt) which is in webapps/test/directory.
    The jsp to read the file is also in the same directory, but my tomcat server is not able to find that file. Where should this file(test.txt) be located.. Lets say the jsp name is test.jsp. Code for test.jsp is
    <%@ page import="java.io.*" %>
    <%
    //response.setContentType("application/msword");
    System.out.println("test1");
    OutputStream ot = response.getOutputStream();
    FileInputStream in = new FileInputStream("test.jsp");
    int bChr = 0;
    while (bChr != -1) {
    bChr = in.read();
    if (bChr != -1) {
    ot.write(bChr);
    ot.close();
    in.close();
    %>
    Please HELP. Thansk a lot. Please reply if you know the answer.

    Hi,
    Try using the complete Path to the file being read. It worked for me - I'm using Tomcat on Windows 2000.
    Instead of
    FileInputStream in = new FileInputStream("test.txt")
    use something like
    FileInputStream in = new FileInputStream("c:\\data\\test.txt")
    This is perhaps because the compiled JSP file is stored in a directly different from the JSP page. If you do not pass the complete path to file name,the generated Java code looks for the file in the directory where the compiled Java Servlet is generated & can't find it there!
    Good Luck.

  • Why? Firefox can't find the file at ....

    == Issue
    ==
    Firefox is crashing or closing unexpectedly
    == Description
    ==
    Why do I get this message all day long? I never did before. Firefox can't find the file at jar:file:///C:/Program Files/Mozilla Firefox/chrome/en-US.jar!/locale/browser-region/region.propertiessz0069.ev.mail.comcast.net.
    == Firefox version
    ==
    3.6.3
    == Operating system
    ==
    Windows XP
    == User Agent
    ==
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
    == Plugins installed
    ==
    *-np-mswmp
    *Adobe Shockwave for Director Netscape plug-in, version 10.3
    *The QuickTime Plugin allows you to view a wide variety of multimedia content in Web pages. For more information, visit the QuickTime Web site.
    *6.0.12.732
    *RealPlayer(tm) LiveConnect-Enabled Plug-In
    *RealJukebox Netscape Plugin
    *Adobe PDF Plug-In For Firefox and Netscape 8.2.2
    *Default Plug-in
    *Shockwave Flash 10.0 r45
    *iTunes Detector Plug-in
    *Windows Presentation Foundation (WPF) plug-in for Mozilla browsers
    *RealPlayer(tm) HTML5VideoShim Plug-In
    *Rhapsody Player Engine Plugin
    *Java Plug-in 1.5.0_02 for Netscape Navigator (DLL Helper)

    The jar: issue can be caused by the Ask.com toolbar or the "ZoneAlarm Spy Blocker Toolbar" or the [http://foxit.ourtoolbar.com/ Fox-it toolbar] (Tools > Add-ons > Extensions).
    See http://forums.mozillazine.org/viewtopic.php?f=38&t=934345

  • When I type in a keyword into the address bar, such as google, it says it can't find jar:file:

    I type in google and this shows up on an error page " File not found Firefox can't find the file at jar:file:///C:/Program Files (x86)/Mozilla Firefox/omni.jar!/chrome/en-US/locale/browser-region/region.propertiesgoogle." It was working just fine a couple of minutes ago

    Try [[safe mode]] please.

  • Help:Can not find the file in jar!

    Hello everyone:
    I build a project using Netbeans 5.0 and make a jar file with it...
    The code in the project as follows will throw an exception described that it can not find the file named datasource-config.xml
    String dataFilePath = getClass().getResource(dataFile).getPath();
    //System.out.println("filepath:"+dataFilePath);
    InputStream input = new FileInputStream(dataFilePath);
    when I run the project with the main() function as an entry it works perfectly and output:
    filepath:/C:/projects/java_project/search/build/classes/com/cn/wxjt/lucene/config/datasource-config.xml
    But when I compressed the project with jar and run it , it will show:
    filepath:file:/C:/projects/java_project/search/dist/search.jar!/com/cn/wxjt/lucene/config/datasource-config.xml
    there is a (!) between search.jar and /com/cn/wxjt...
    I dont know why I generate a ! symbol in the file path... Is it cause the exception->
    java.io.FileNotFoundException: file:\C:\projects\java_project\search\dist\search.jar!\com\cn\wxjt\lucene\config\datasource-config.xml
    If you have any idea, plz tell me.
    Thank you and best wishes to you !
    :)

    If the file you want to read is in your jar file, use
    getClass ().getResourceAsStream
    (relative_path_file_name)Hope that help,
    Jackhey jack i want to open the file as new File
    i m using this.getClass().getResource("resource/backend.xml");
    the resource is the directory inside the jar file.
    when i prints the url it shows:
    the jar file is in the WORK directory
    URL : jar:file:/home/neeraj/WORK/show.jar!/resource/backend.xml
    now when i creates new File using the url.getFile() method the file does not exist.
    although the same programs runs well when i uses the InputStream
    so plz tell me cant I create a new File from the above method????
    thanks in advance
    with regards
    neeraj

  • Had to uninstall Firefox, now I can't reinstall. Get error message "Can not find archive file." Please help!

    I believe I had some kind of virus attack. I got everything cleaned up. (I HOPE) In the process of cleaning the virus, I unintalled Firefox because it wouldn't open. Kept getting the error message that Firefox was already open and I had to close out of the sessions or restart the computer. After restarting the computer several times and not being able to find any open sessions in task manager, I uninstalled. When trying to reinstall, I get the error message "can not find archive file." I've tried downloading Firefox from cnet as well as the Mozilla site to no avail. Please help. I'm getting tired of using Chrome already!

    Hello,
    Certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you remove Firefox program files and then reinstall Firefox. Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from http://www.mozilla.org and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (click Exit from the Firefox or File menu).
    #Delete the Firefox installation folder, which is located in one of these locations, by default:
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    Please report back to see if this helped you!
    Thank you.

  • Firefox can't find the file at (a location is specified) when either "Navigate previous" (and next) buttons are pressed in an HTML5 skin (but OK in IE/Chrome).

    I create HTML5 help projects from a package called MadCap Flare. It uses what they call an HTML5 'skin' that sets the style/layout of the page and also includes 'Navigate previous' and 'Navigate next' buttons. When viewing the help and pressing these navigate buttons in IE8 or Chrome 32 there is no problem, but in Firefox 27 I get the following: (typical error for pressing a button on any page)
    "File not found"
    "Firefox can't find the file at /C:/SVN/FlareEnglishOnLineHelp/Output/HTML5_Help_Modeller_Reference/4attrib/idh_jointinterface_element_meshes.htm?TocPath=Modeller Reference Manual|Chapter 5 : Model Attributes|Meshing|_____2."
    " Check the file name for capitalisation or other typing errors."
    " Check to see if the file was moved, renamed or deleted."
    - Because the files and buttons work in other browsers I'm wondering just what is going on here with Firefox>>>>

    I should correct that last entry and state that the | charactacters are generated automatically in the Toc-Path for each 'book' name in the online help, and are not something manually created, whereas the : characters have come from the TOC book topic names (which were manually entered names and are what we would ideally require). But, because 'previous' and 'next' topics within nested TOC books without colon (:) characters CAN be browsed successfully when just | characters are present in the Toc-Path, the limitation would appear to be solely due to the : characters.

Maybe you are looking for

  • GR Document

    Hello Experts, I have a FI document ( Dr GR/IR Account, Cr Vendor Account) and i need to find out the Vendor Invoice Number ( or MM document) from this one. How do i find out? I am guessing that if i find the GR document ( Dr Inventory, Cr GR/IR docu

  • Master Detail form on Oracle EBS

    Hello, This is on Forms 6i, on Oracle EBS 11.5.10.2 I have a Master Detail Form, with one master block and several detail blocks(5 detail blocks). Each of the detail block is arranged on a tab. That means 5 detail block = 5 tab. Now I wan to implemen

  • Are 3

    hi, i'm unable to print are 3 even print preview is not coming IN TOCDE J1IA302 pl let me know is this the correct Form J_1I_ARE1 for o/p type J1IB

  • SAP NOTE: 1787850 -  ESS Config EHP6

    1787850 - RDS for employee & manager self service in NW portal V3.606 Hi all, Can we use above note for general SAP ESS config or is it just for RDS! Also please send me any other useful links for portal config. What extent of Enterprise portal knowl

  • I just bought my macbook and ever 15 minutes there like bubble sound coming from my macbook which is very annoying and I don't know where this sound coming from?

    every once in a whiel, randomly, my macbook retnia display which I just purcheased will make a weird bubble sound. it's not the sound that it makes when you send a text message, it's some other sound. but it happens randomly. i can't figure out what'