Problem dealing with files in jsp

I am working on a web application developed using jsp-struts
In one of the Java Action classes I need to display the content of a text file in a textarea at the clientside form.
For this purpose when I'm using the following code, i got a problem stating FileNotFoundException:the system cannot find the file specified
FileReader fr=new FileReader("/templates/file1.txt");
I've placed file1.txt in templates folder under my web-app-root/WEB-INF/classes folder
Plz help

Use the Class / ClassLoader methods - getResource() or getResourceAsStream() methods.
This (http://www.javaworld.com/javaqa/2003-08/01-qa-0808-property_p.html) shows how.
cheers,
ram.

Similar Messages

  • How to deal with file(for example .xml)? what format of dir should be?

    I'd like to operate the file in disk, and want to use relative directory?
    How to deal with file dir? what format of dir should be?

    Hi Kamlesh,
    Thanks for your response.
    Actually, In the "Process External Bank Statement" window, i see that there are few entries which is for the previous year and which has not been reconciled. I have never worked practically on BRS and hence, i am scared to make any changes in the clients database without being confident on what i am doing. I need to reconcile for one of their Bank a/c for the month of April '08. I have the copy of the statements for the month ending 31st Mar 08 and 30th Apr 08. The closing balances are as below:
    31/03/08 - 2300000.00
    30/04/08 - 3100000.00
    Now my OB for Bank a/c for April '08 in SAP is 2300000.00 Dr.
    When i go to External Bank Reconciliation - Selection Criteria Screen (Manual Reconciliation), here are the detail that i enter:
    Last Balance: INR -7,000,000.00000 (Grayed out by the system)
    Ending Balance: INR -3,100,000.00000 (Entered by me)
    End Date: 30/04/08 (Entered by me)
    "Reconciliation Bank Statement" Screen opens up and shows the below balances in the screen:
    Cleared Book Balance: INR -7,000,000.00000
    Statement Ending Balance: INR -3,100,000.00000
    Difference: INR 3,800,000.00000
    As per the Bank statement, i have found all the transactions listed out here for the month of Apr '08 but, i also found that the open transactions for the previous month from April '08 have been lying in "Process External Bank Statement" window.
    Could you please help me solve my issue as to what needs to be done or could you also get me some links from where i can get few documents for processing External Bank Reconciliations?
    That will be of a great help for me. I need steps as to what needs to be done first and then the next so that i can arrive at the correct closing balance for the month April '08.
    Thanks in Advance....
    Regards,
    Kaushal

  • How to deal with file sequences in importer plugin

    I checked the sdk example which deals with file import. What would be the difference if I would want to create an importer for a file sequence? Let's say I have a sequence of file0001.img, file0002.img,...,file1000.img. If I enable the image sequence import in media browser I should be able to import this 1000 files as one clip. However I don't see how PP will tell me that this is not just one image. It gave me the first filename and told me to open it, and as my code is not finished yet I could not go any further. What should I expect?
    Thanks,
    ajaj

    you could try using a Java Mapping to change the encoding manually. For that, set the encoding of the OutputFormat of the XML you'll serialize. Try the following code piece for the mapping (inside a try/catch declaration):
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = factory.newDocumentBuilder();
    Document input = documentBuilder.parse(in);
    OutputFormat format = new OutputFormat(XML, "ISO-8859-1", false);
    XMLSerializer serializer = new XMLSerializer(out, format);
    For more details check this guide:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42

  • Problem loading resources file in JSP using f:loadBundle

    Hi,
    We are facing problem while loading our properties file in JSP using f:loadBundle.we tried the following way
    <f:loadBundle basename="resources.ApplicationResource" var="msg"/>
    This properties file is src java folder and also in WEB-INF-->classes->resources folder
    but even then its not able to load.I made an entry in the faces-config for message-bundle. But of no use.
    Any pointers would be of great help.

    does your file calls
    ApplicationResource.properties ?
    If so is it in
    the package resources ?

  • How to deal with files ?!!!!

    hiii, guys i dont believe that a huge program like flash with
    all these abilities doesnt deal easily with files !!! I just want
    to do simple reading and writing to text files. Something veryyyyyy
    simple like writing a name and reading it again later
    !!!!!!!!!!!!!!!!!! i know how to load them by using loadVariable()
    ,,, but how can i write to the file ?!! it's really annoying if i
    have to use asp scripting or xml or ... to do such easy job !!! i'm
    facing difficulties because i know ActionScript and VB and C++
    only,,, I dont know how to deal with asp and xml !!! @_@
    But, if this is the only way to do this, plz tell me in steps
    how to write a name and read it again in flash, THANX

    If you are sticking to those three languages and you have
    Flash CS3, you may want to consider publishing to an AIR
    application. Adobe's done a lot of work to keep the security tight
    on Flash Player which is one (if not the only... not sure) reason
    that you cannot do this with Flash alone. You would have to use a
    server-side script to accomplish what you want with Flash Player.
    Here is a tutorial on an AIR app that writes to txt files:
    http://www.adobe.com/devnet/air/flash/quickstart/building_text_editor.html

  • Last Q of the day (dealing with file saving)

    When I save my data to the file it gives me a bunch of tabs and stuff that I don't know how to fix. I tried match pattern, and remove white spaces and neither did if for me. Is there a way that I can get it to only output spaces, periods, and commas?

    Simple suggestion - reccomend you try my VI version 2 (from the first thread) and see if that gives you th same string out. If not, it is because you are adding in extra random spaces in the pig latin subVI. I noticed that you deal with spaces in a funny way and had to do something to avoid that.
    James
    edit:
    (Last post of the day - have a nice weekend)
    I have debugged the spacing in my VI loads, I can only debug your subVI so much
    Suggest you just read file in, wrte string into VI, and write string straight out of VI. It'll take you 5 mins to try.
    Message Edited by James W on 04-16-2010 01:03 PM

  • Scripting problem dealing with Acrobat 9's extra (unwanted) nodes

    Hello All,
    I'm having a few issues with the way Acrobat 9 creates extra nodes in the model tree when you try to export it
    out as a u3d.  Here's what i mean.
    In version 8, my object tree looks something like this:
    <Node Name="model">
           <Node Name="DTM">
                 <Node Name="D1"/>
                 <Node Name="D2"/>
                 <Node Name="D3"/>
                 <Node Name="D4"/>
    But, when i export the same model in version 9, the object tree looks something like this
    <Node Name="model">
           <Node Name="model.u3d">
                 <Node Name="DTM">
                      <Node Name="D1">
                             <Node Name="D1"/>
                       </Node>
                            <Node Name="D2">
                                  <Node Name="D2"/>
                       </Node>
                       <Node Name="D3">
                             <Node Name="D3"/>
                       </Node>
                       <Node Name="D4">
                             <Node Name="D4"/>
                       </Node>
    Acrobat 9 adds a new level of nodes.  This is a problem for me as i have been using a simple script to toggle my
    objects on/off.  The script that i've have been using:
    var Context = getAnnots3D(0)[0].context3D;
    var mesh = Context.scene.meshes.getByName("D1");
    mesh.visible = !mesh.visible
    This works fine under version 8 but not in version 9. I'm assuming that with the new level of nodes, i have to alter my script to reflect this. Does anyone know how i can adjust my script to make this work with all these extra nodes?
    Thanks

    I think I have isolated the source of this problem. It's the Pitstop Professional 9 plug in. I un-installed this, and everything opens quicker than greased lightning. I re-installed it and it's back to slowsville.
    Unfortunately Pitstop is essential to my workflow.
    Until recently I did my pre-press on a Mac G5 with Acrobat Pro 7 and Pitstop 6.5. I never had this problem with slow file opening. But it seems that the delays would occur when I used the plug-in with large complex files.. So it would open files as fast as you'd expect from an elderly machine. But starting to use Pitstop would result in a prolonged period of staring at a spinning beachball.
    I wonder is there any way to stop the Pitstop plug-in from initializing until it is used? So the plug-in stays inert until you select the tool from from the menus.

  • Problem facing with file upload in webdynpro

    hi
    this is sathya, i very thank ful  to your answers, coming to my problem
    i have written the code for file upload action method, in this below code there is no syntax problem.
    but there is a run time error , i.e convt_no_number
    kindly rectify that.
      data:  lt_final type table of zalvtab,
             ls_final type zalvtab,
             "t_table1 TYPE STANDARD TABLE OF str_itab,
             "fs_table TYPE str_itab,
             i_data TYPE STANDARD TABLE OF string,
             lo_nd_zalvtab TYPE REF TO if_wd_context_node,
             lo_el_zalvtab TYPE REF TO if_wd_context_element,
             l_string TYPE string,
             l_xstring TYPE xstring,
             fields TYPE string_table,
             lv_field TYPE string.
      DATA : t_table TYPE if_main=>elements_sel_node,
             data_table TYPE if_main=>elements_sel_node.
    " get single attribute
        wd_context->get_attribute(
           EXPORTING
           name =  `upload`
           IMPORTING
             value = l_xstring ).
      CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
        EXPORTING
          in_xstring = l_xstring
        IMPORTING
          out_string = l_string.
        SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE i_data.
    " Bind With table Element.
       LOOP AT i_data INTO l_string.
        SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.
        READ TABLE fields INTO lv_field INDEX 1.
        ls_final-ebeln = lv_field.
         READ TABLE fields INTO lv_field INDEX 2.
        ls_final-ekorg = lv_field.
         READ TABLE fields INTO lv_field INDEX 3.
         ls_final-bukrs = lv_field.
         READ TABLE fields INTO lv_field INDEX 4.
         ls_final-ebelp = lv_field.
          READ TABLE fields INTO lv_field INDEX 5.
         ls_final-menge = lv_field.
         READ TABLE fields INTO lv_field INDEX 6.
         ls_final-netpr = lv_field.
         READ TABLE fields INTO lv_field INDEX 7.
         ls_final-aedat = lv_field.
         READ TABLE fields INTO lv_field INDEX 8.
         ls_final-waers = lv_field.
         READ TABLE fields INTO lv_field INDEX 9.
         ls_final-description = lv_field.
          APPEND ls_final  TO lt_final.
      ENDLOOP.
      lo_nd_zalvtab = wd_context->get_child_node( 'sel_node' ).
    lo_nd_zalvtab->bind_table( lt_final ).

    Hi Sathya,
             I guess you are trying to upload data from excel file(XLS format).
             If it is correct then you cannot do this in webdynpro, first you save the excel file as tab delimited.
             Open your excel file->save as->other formats->give file type as TEXT(Tab delemited).
             Now use this file to upload. It should work perfectly.

  • Outlook 2010 has problems dealing with in-line attachment (not an Exchange issue!)

    Hi all...
    Is there an official way to have this bug looked at? 
    (Note -- it is *not* the Exchange/PDF bug that has been semi-addressed with the very-recentInterim Update for Exchange 2007...)
    If I set up Outlook 2010 to use an IMAP server account (not an Exchange account) and send that account a message from Apple's Mail.app program -- that contains an in-line attachment -- Outlook 2010 displays the e-mail incorrectly.
    If I send e-mail using Apple Mail of the form:
    <some text>
    attachment  (and in this case I've tried .pdf, .docx, .xls, etc. -- it seems not to matter what the attachment is...)
    <additional text>
    <signature>
    Outlook 2010 displays the resulting e-mail with a problem:
    The received e-mail will look like this
    <some text>
    then *two* attachments -- the attached file *and* an "Untitled Attachment" that contains the <additional text> and <signature> parts of the e-mail (!)
    The reproducible bug (at least here) is that Outlook 2010 should display the remaining text after the in-line attachment within the *body* of the e-mail message.
    Again, this is *not* the recent Exchange issue with .pdf files -- this is strictly an Outlook issue.
    Any thoughts/help on this one?
    - Steve

    Hello,
    In order to get a better understanding of your issue I have a few questions:
    1: You mention that the sending client is an Apple mail application. Do you see this issue when sending from a non-Apple email client?
    2: Which version of Apple Mail app are you using?
    3: If you send the same mail to an Outlook 2007 or earlier version of Outlook do you see the same issue?
    4:  What is the format of the Email when being sent from the Apple mail client, is it HTML; Plain Text or Rich Text? Additionally, what happens if you send the same email but change the format.
    5: If you send an Inline attachment to the Apple Mail application from Outlook 2010, what happens?
    6: As per the Post you are attaching a single Inline attachment with text before and after the attachment before sending the email, but when you receive the mail in Outlook you get two attachments. Are these attachments still inline attachments?
    7: The second file attachment; next to the remaining text and the signature does it contain any other text? Like some error added by the server?
    9: Instead of .pdf, .docx, .xls file if you send an image as an inline attachment from the Apple mail application, then so you see the issue?
    10: If you send the files as normal attachment not inline does everything work?
    Below is an article which may be applicable to your issue although it pertains to an earlier version of Outlook:
    ‘Outlook renders inline message information as an attachment’
    http://support.microsoft.com/kb/814111
    I also came across a user who experience similar issue and they suggested, setting the apple mail application to Always insert attachment at the end of the message.
    View->Attachments and select "Always Insert Attachments at End of Message
    Let me know what the results are using that setting.
    Do let me know if you have any queries regarding the same and I shall try my best to address it as far as possible.
    Regards,
    Harveyy - MSFT

  • Problem viewing PDF File in JSP

    Hi,
    I have the file location of a PDF saved in the database.
    If I modify the PDF file on my directory and then try to view it in my browser, it still shows the old file .. (I do not modify the pdf file name)
    However, when I close my browser and reopen it, it shows up okay. this looks like a browser level problem but can someone give me an idea on how I can solve this problem within my JSP...
    Here is some code to view the file
    <a href="<%= response.encodeURL(fileLocation) %>"><%= binderName + ".pdf" %></a>
    Thanks,
    Yasir

    The problem you are having is a browser cache issue. If you open the same URL, the browser is trying to save you time by giving you what it got last time. The trick is to make the URL different each time it is opened. Just append a hash or some other unique code:
    Instead of:
    http://myserver/pdfMakerServlet/newpdf.pdf
    Use this:
    http://myserver/pdfMakerServlet/newpdf.pdf&012345
    If the URL is different each time, the browser will ask the server again for the file.
    Does this help?

  • Problems working with files on network - RH9

    I store my RH WebHelp source files on our company network. I follow Peter Grainge’s excellent advice on merged help by generating and publishing merged help to my local drives but I also publish to a second network location to make the help available generally. This worked fine till recently but lately severe performance problems have arisen. RoboHelp takes a long time to start up and even longer to open a selected project. Publication to a network location is so slow it’s no longer feasible. The tardy response to editing commands makes RoboHelp effectively unusable.
    I’ve tried some fixes including those mentioned here on the forum. I installed the latest RH updates. Stopping non-windows services had no effect. I considered reinstalling in XP Mode but I’d prefer to avoid this option. Some Windows 7 tips I applied to improve network performance did no good. I drew a blank with our own company IT experts.
    The only change to my local environment or to the network environment I’m aware of is that I took a Windows 7 recommended upgrade just before the problems set in.
    I’ve had to resort to moving my source files to my local machine. This is not ideal from an information security point of view and in any case, publication to a network location from within RoboHelp is still not practical. I use RH 9 (version 9.02.271) on Windows 7 (SP 1), both updated in the past few days. I use a Lenovo W520 laptop: 2.7 GHz, 8 GB Ram, 64 bit OS.
    I’d appreciate any suggestions which would allow me to open and edit projects directly from the network.

    Colum, while RoboHelp 10 has "improved" upon network usage, I'm not sure it's recommended. Heck, I'm not sure I'd even claim it's safe!
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • Problems working with files on Win2k SP4 server

    I installed 10.5 to test it before rolling it out to our designers. As part of my normal routine, I organized DVD sized folders of job files to copy from the server and burn of to disc for archiving. I am connected to the server via SMB. In this process I had a few observations:
    1. A directory that the Finder registered as 4.21GB on the server copied to the desktop as 5.45GB. Apparently the finder isn't updating the directory sizes automatically.
    2. When trying to move a group of folders I received a permissions error, but I could move them individually without incident.
    3. The empty folder I had moved the files from still showed 30ish K of data in the finder though there were no visible files present. Most likely the usual hidden files, but not being handled properly by the finder.

    Colum, while RoboHelp 10 has "improved" upon network usage, I'm not sure it's recommended. Heck, I'm not sure I'd even claim it's safe!
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • My problem deals with the url bar.

    Before switching to 5.0, I was able to type in let's say something like, "Imdb.com jack nicholson" into the url bar & I would end up on the actors Imdb profile, but now since I switched, it just re directs me the google search for his page. So, is there something I can do or re config to back to the way it once was? Thanks!

    There is a change beginning in Firefox 4 in how Location bar search works.
    *'''''In Firefox 3.6.x''''', Location bar search uses Google "Browse by name" search. With the browse by name search, it performs a Google search and
    **if there is a clear match it will take you to the site
    **otherwise it shows the Google search result page
    *'''''Firefox 4's default''''' is
    **to perform a Google search and present the Google search results page '''''if''''' you type something which is not recognized as a URL
    **you must type a complete URL, such as www.youtube.com , to go directly to the site
    To get the Firefox 3.6.x behavior in Firefox 4. you need to change a hidden preference '''''OR''''' install the add-on below.
    '''To change the preference:'''
    #Type '''''about:config''''' into the location bar and press the Enter key
    #If you see a warning, accept it (promise to be careful)
    #A list of preferences will open
    #Filter = keyword.URL
    #Double-click on that preference in the lower pane
    #A small window will appear; copy one of the URLs below and paste into the box in that small window (or type it into the box in that window '''''exactly''''' as shown below):
    *Google "I'm Feeling Lucky": http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q=
    *Google "Browse by Name": http://www.google.com/search?ie=UTF-8&sourceid=navclient&gfns=1&q=
    '''Instead of the above, you could install this extension:'''
    *'''''Browse by name''''' add-on: https://addons.mozilla.org/firefox/addon/browse-by-name
    See:
    *http://kb.mozillazine.org/About:config
    *http://kb.mozillazine.org/Keyword.URL
    *http://kb.mozillazine.org/Location_Bar_search
    <br />
    <br />
    '''You need to update the following.''' The Plugin version(s) shown below was/were submitted with your question and is/are out of date. You should update to avoid known security issues with the version(s) you have installed. Click on "More system info..." to the right of your question to see what was included with your question.
    *Adobe PDF Plug-In For Firefox and Netscape "9.3.4"
    #'''''Check your plugin versions''''' on either of the following links':
    #*http://www.mozilla.com/en-US/plugincheck/
    #*https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #*There are plugin specific testing links available from this page:
    #**http://kb.mozillazine.org/Testing_plugins
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**SAVE the installer to your hard drive (save to your Desktop so that you can find it after the download). Exit/Close Firefox. Run the installer you just downloaded.
    #**Use either of the links below:
    #***https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox ''(click on "Installing and updating Adobe Reader")''
    #***''<u>Also see Download link</u>''': http://get.adobe.com/reader/otherversions/
    #*After the installation, start Firefox and check your version again.

  • Problems dealing with huge amounts of email!  Help!

    I have my own business and receive about 200 emails
    per day, mostly spam email.
    When iPhone synched to my email accounts it downloaded
    about 1500 emails that I suppose it pulled off my server
    (although I have been deleting them off my Mac daily).
    In any case, with this much email, iPhone cannot handle
    deletions. From what I see there is no option for a mass
    delete and I have to sit here and delete each message
    one-by-one.
    Additionally, while deleting in this manner, the iPhone
    locks up after a handful of deletions, probably because
    it can't process those deletions very fast. After a few
    minutes of freeze-up I am able to continue deleting
    more messages.
    Anyone having email deletion lockups, and more importantly,
    has anyone found a way to do a MASS DELETION of email?
    Look forward to your replies.

    It may be too late, and I don't have a direct answer to your question, but maybe a possible solution going forward. Setup the push email via yahoo, then have your email coming into your business addressforwarded to the yahoo account. Now any new email coming in will go to the yahoo push account and you won't get bogged down by retrieving old email off your server. Plus you will use less battery checking email as the push will just send it to the phone instead of having to check it. Just a thought....

  • Problems dealing with Boolean data types(SQL).

    Greetings.
    Below is an sql code i am trying to execute.
    select Band, Memb_contact =
    CASE 
    when contact_person >= 0 then 'Yes'
    else 'No' 
    end, Club_Name, Club_contact
    from Members, Club
    where contact_person = 'Yes'
    My column contact_person has a data type of boolean. It stores 1 and -1 only.
    I'm am trying to execute the select statement to return The Band Name and contact number only if the person
    is identified as a contact person in the members table.
    It return the following error:
    Msg 245, Level 16, State 1, Line 1
    Conversion failed when converting the varchar value 'Yes' to data type bit.
    Please help.

    Try the below: You can not have 'Yes' instead use 1.
    select Band, Memb_contact =
    CASE 
    when contact_person >= 0 then 'Yes'
    else 'No' 
    end, Club_Name, Club_contact
    from Members, Club
    where contact_person = 1

Maybe you are looking for

  • HP Pavilion Elite m9258 will not boot up. Won't recognise USB ports -mouse keys etc

    HP Pavilion Elite M9258 70 percent of the time will not boot up. Computet light is on. DVD drive will open and shut. Fans sound slightly quieter when this happens. The monitor comes on but the light goes to  orange. When I press any of the monitor bu

  • Coordinate system in illustrator

    Hi. I'm trying to build a shape in Illustrator CS6, OSX 10.7.5, using a script with setEntirePath. I begin with: var aPoints = new Array ([20, 50], [60, 30]); pShape = app.activeDocument.pathItems.add(); pShape.setEntirePath(aPoints); I expected a di

  • Feedback on amazonmp3 for amd64

    Hey folks, I've put together an amazonmp3 pkgbuild for amd64 machines and I'd like to get some feedback and help polishing it.  It grabs the packages required from the ubuntu repositories and puts everything into /opt/amazonmp3/.  There's also a scri

  • MDM Logs

    HI MDM Gurus, where can i see logs for MDM server. i see there is a log table in Admin part of console. Also there are log files in Distribution folders. Thanks. Jyoti

  • XA transaction performance

    Hi, I'm using Weblogic for JMS (using MDB to process messages) and Coherence as a Caching solution. My MDBs are under transaction and I want to perform operations on Coherence using the same transactions. to do such a thing I installed Coherence JCA