Check the existence of a picture into an application

Hello, I'd like from a servlet be able to check if a picture exists or not.
Here is my code
String flagUrl = contextPath + "/images/flags/" + name.trim().toLowerCase() + ".png";
boolean exists = (new File(flagUrl)).exists();                                                         Always returns True while should sometimes returns False.
Edited by: intevit on Feb 24, 2010 7:42 AM
Edited by: intevit on Feb 24, 2010 7:43 AM

If contextPath contains the contextPath, that could be the problem, you should get the realPath instead.
Bye.

Similar Messages

  • HT1338 When I email an attachment with "Always Sent Windows-Friendly Attachments" checked, the result is a picture embedded in the body of the email, not a attachment.  What am I doing wrong.

    When I email an attachment (a .jpg file) with "Always Send Windows-Friendly Attachments" checked, the result is a picture embedded in the body of the email, not a attachment.  What am I doing wrong.

    1. "Always Send Windows-Friendly Attachments" has nothing to do with the display of attachments on either your machine or other ones. It's an esoteric setting that strips the resource fork from Mac files (that might have them) which could apper as a duplicate file on the Windows machine.
    2. Send Plain Text emails. Then it will always be received as an attachment.

  • Is there any FUNCTION I can use to check the existence of a USER?

    Hi,
    Is there any FUNCTION I can use to check the existence of a USER? I dont want to write a function by myself to access usr01 directly.
    Thanks in advance.

    You can use FM USER_EXISTENCE_CHECK
    Thanks
    Seshu

  • How to check the existence of DB400 library from java

    Hi all,
    I actunally need to validate a DB400 library via java. so is there any way to check the existence of DB400 library from java side.
    Thanks in advance.

    Hi Sarvan,
    You might not even need a function to tell you if a record exists or not.
    Here in below example i do a check with exists .you will find couple of other ways too..
    create table t as select * from emp where deptno=10now i set salary of every person present in table 'T' to 1111 in emp table.
    update emp e
    set sal=1111
    where exists
            (select 1
              from t
              where t.empno=e.empno) Remember that plain SQL will always outperform PLSQL.
    Hope it helps
    CKLP
    Edited by: CKLP on Sep 26, 2011 3:41 AM

  • How to check the existence of file without any error dialog?

    Hi everybody,
    I am trying update some labview programs from LV6.1 to LV7.1, I used the
    function "File/Dictionary Info" to check if the file
    exists or not (if the size=0 then file does not exist), and it ran well with
    LV6.1, but now it shows every time a labview error dialog
    about "LabView: file not found..." with 7.1, if this file dosn't exist.
    Sometimes I feel that it is really stupid to show the dialog, because I
    can write handling by myself, if the error should be handled, and
    I don't want all the process is interrupted because of such dialogs. Is
    there any way to shut the dialog down or check the existence of
    file smoothly?
    Thanks a lot!
    L.Wang

    Hello,
    The dialog is probably appearing because you have Auto Error Handling turned on.  This feature is turned on by default in LabVIEW 7.0.  You should go to VI Properties (Ctrl-I) > Execution and deselect "Enable automatic error handling".  Also you should go to Tools > Options > New and Changed in LabVIEW 7.x and deselect "Enable automatic error handling in new VIs".  If you never want to see one of those dialogs again, you can also deselect "Enaeble automatic error handling dialogs"...I wouldn't recommend this, however, as you would never know if one of your VIs had this setting enabled...you would only find out once somebody else tried to use your VI on another LabVIEW install.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Procedure to check the existence of Indexes

    I have a procedure whcih drops all the indexes, when the same procedure is executed again, it gives error "object does not exists" (obviously)
    I want to avoid this error, how can I check the existence of index inside the procedure, so that the procedure will check if the index exists before deleting the index?
    Is there a ready-made procedure available for such scenario?
    Thanks in advance

    The other approach is to catch the exception in your script, i.e.
    BEGIN
      EXECUTE IMMEDIATE 'DROP INDEX <<index name>>';
    EXCEPTION
      WHEN OTHERS THEN
        -- Drop failed.  Do something to record the failure.
        NULL;
    END;Now, most of the time, you'll want to catch a few specific exceptions and you'll want to do something when you catch them (i.e. generate a log entry).
    Justin

  • Programmatically check the existence of objects in the system

    Hi,
    Is there a way to programmatically check the existence of objects? The idea is I'll accept a list of names of objects and their object types and then programmatically check their existence in the system?
    Can you point me to a resource on how to do it?
    Thanks in advance.
    --Carl

    Hi.
    All custom objects (z, y) being referred to a program. May it be z or y table, data element, domain, sapscript form, function module/group.
    The goal is actually to be able to transport a program from a source machine to a target machine. The objects being referred to from the program must also be transported, of course, for it to run properly. Thus, the need to check the objects' existence.
    Thanks.
    --Carl

  • [svn:bz-trunk] 23143: Certain code needs to check the existence of the class validation validator  (some brokers and other listeners) during message broker init, however the validator was not being created till the very end of the method .

    Revision: 23143
    Revision: 23143
    Author:   [email protected]
    Date:     2011-10-27 06:31:02 -0700 (Thu, 27 Oct 2011)
    Log Message:
    Certain code needs to check the existence of the class validation validator (some brokers and other listeners) during message broker init, however the validator was not being created till the very end of the method.  Promote it to be at the top instead of at the bottom.
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/config/MessagingConfiguration.java

    Revision: 23143
    Revision: 23143
    Author:   [email protected]
    Date:     2011-10-27 06:31:02 -0700 (Thu, 27 Oct 2011)
    Log Message:
    Certain code needs to check the existence of the class validation validator (some brokers and other listeners) during message broker init, however the validator was not being created till the very end of the method.  Promote it to be at the top instead of at the bottom.
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/config/MessagingConfiguration.java

  • Any means to check the existence of a .pdf file before opening in SAP GUI

    Dear,
    I've learnt from one of the thread that there is a sample program SAP_PDF_VIEWER_DEMO that allows us to open a .pdf file within a SAP windows.
    However, I would like to know if there are any means to perform a checking on the existence of the .pdf file first before calling the method open_document as coded in the demo program.
    Thanks a lot for your advise in advance,
    Francis

    where is this pdf file is ? in user desktop?
    if yes you can simply use cl_gui_html_viewer for viewing pdf files. and you can use cl_gui_frontend_service=>file_exists method to check whether the file exists
    Raja

  • Checking the existence of a file b4 creating a file by the same name

    Hi All,
    I hav a scenario where I hav to check for the existence of a file by the same name (<b>XXXFile</b> say). If i don't hav any file by the name <b>XXXFile</b>, then i hav to create a file by the name <b>XXXFile</b> at that location. If it already exists, then i hav to wait till it gets deleted (takes hardly 1 min to get deleted).
    Can any one tell me :
    How to do this without using operating system command?
    And using operating system command?
    Any help wud be appreciated.
    Thnx in Adv
    Anil

    Hi Anil,
    You will i guess have a standard format in which you are going to write the file with a counter or something.
    Whenever you are going to write a file, you can:
    1. Check if there is a file already sent by this name?
    2. If no, then you can send the file at the same time update the name.
    You can do this by creating a ztable in SAP and accessing it through JCO/RFC. You can do this in your module or in the mapping.
    eg. /people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i
    Regards
    Vijaya
    Message was edited by: vijaya kumari

  • Check the existence  of sales order

    Hi all,
    I am working on the scenario Jdbc to SAP(BAPI's).In Jdbc there is a flag field which indicates the status whether it is create or update or delete.I am using recieve and steps in BPM.
                 If it is create i have to first check whether already sales order is presented in the SAP data base.If it is already there ,then it must update the existing salesorder with create option.
                 similarly with update also...
    How can i check the data existed in SAP database in BPM ?
    Could anybody please help me?
    Thanks,
    sekhar.

    you receive a jdbc "data type" and you want to post an rfc to check if the sales order is created so
    you have to map the "jdbc" to RFC (transformation step)
    then after the swith you can map your "jdbc" again to your z_bapi which now will create or update a sales order for instance
    now a little bit clearer?
    Regards,
    michal
    Message was edited by: Michal Krawczyk

  • Checking the Existence of Flat File

    Hi,
    I want to know whether a flat file is existing in the presentation server.
    I want to check the text file's availability and upload if it is there using GUI Upload.
    Regards
    Anil

    Hi,
    Try this.
    AT SELECTION-SCREEN ON p_file.
      PERFORM f_validate_file.
    FORM f_validate_file .
    *VARIABLE DECLARATIONS
      DATA:loc_result TYPE abap_bool,
           loc_file TYPE string.
      loc_file = p_file.
    *Checking the file exist or not
      CALL METHOD cl_gui_frontend_services=>file_exist
        EXPORTING
          file                 = loc_file
        RECEIVING
          result               = loc_result
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          wrong_parameter      = 3
          not_supported_by_gui = 4
          OTHERS               = 5.
      IF loc_result = wl_space.
        MESSAGE e368(00) WITH text-003.  "ENTER CORRECT FILE PATH
      ENDIF.
    ENDFORM.                    " F_VALIDATE_FILE
    Regards,
    Rohan.

  • File problem - checking the existence of a remote file

    I have absolute paths to several text files from a ftp server (which don't require any
    authentication and can be accessed over the internet).
    I am trying to write a Java method that can check any of the above absolute ftp file
    paths and returns true/false depending on whether the file exists/doesn't exist.
    I tried somewhat this way:
    File current_file = new File(absolute_file_path);
    // absolute_file_path comes as a parameter
    // e.g. "ftp://ftp.test.com/myfile.txt"
    if(current_file.exists()) return true;
    // if the file exists return true
    return false;
    // otherwise return false
    Then I ran the program in my local machine which has internet access. But it returned
    false for all the files (even if the file exists). Seems like it's unable to get those
    files.
    Could someone please tell me how can I rewrite my program so that it can be executed
    locally.
    Thanks,
    SQ

    Does anyone know if URL and URLConnection support FTP
    directly? I can imagine downloads being simple, but
    how about uploads? Never tried with FTP myself.Yes, they do. But uploads don't work properly with Java 1.3. (Note: I only know this because I've seen questions asked about it here, not from personal experience.) If I wanted to know whether a certain file existed on an FTP server, I would use an FTP client that could tell me that. Such as the Jakarta Commons/Net FTP client.

  • How to check the existence of a file?

    Hi,
    I want to know how to use FileNotFoundException to check whether a text file exists in local directory.
    How should I do the code?
    Thanks
    gogo

    Like this:
    private File f = new File ("c:\\projects\\sutil\\err\\temp_err.txt");
       if (f.exists()) {
          f.delete();
       }

  • How to check the number of digits entered into a itab-field.

    Howdy,
    I've got a program where i retrieve some data from the database and then I need to check if field BKPF-XBLNR has exactly 15 digits in it.
    I've got no idea on how I would do this...
    Can anyone help?
    Thanking you kindly!

    XBLNR is a character field.  If you want to make sure all 15 positions have a digit and not some other character then use:
    IF BKPF-XBLNR CO '0123456789'.
    * OKAY, all 15 positions have digits
    ELSE.
    * NOT OKAY, at least one of the 15 is not a digit
    ENDIF.
    If you do not care what the characters are, then Rich has given you the solution but be aware that you could have embedded blanks, for example:
    'ABCDEF    GHIJK'
    is length 15.
    Message was edited by: Charles Folwell

Maybe you are looking for

  • Can we add our own menu in sap easy access screen

    can we add our own menu in sap easy access screen along with the existing menu items... ex : can i add the new menu item as help1 on that screen regards    raghu

  • Crystal Report Viewer issues

    Hi, I'm starting with CR viewer for CR 2008 in VS 2008. I have 3 problems. Look like easy problems, buy during the morning, I didn't found any solution. 3 questions: - I want CR viewer  like "dock = fill". viewer size 100% height and 100% width. I se

  • The Windows Ribbon Breaks After Selecting The Photo Stream Library

    Using the latest iCloud (2.1.2.8). The Windows File Explorer's Ribbon's buttons stop working after clicking on the Photo Stream library on the left. Specifically what breaks is ribbon's buttons. It is as easy as clolsing the file explorer window then

  • Cannot install Windows server 2003 SP1

    Hi all,do you know something about "Not enough free space" issue when upgrading windows 2003 under bootcamp with Service Pack 1? I'm going crazy but it seems it is an issue related to "boot camp" or well "on macintosh install". I get an error message

  • NAC not checking the Window hotfix policy eventhough the hotfix is installed

    I need a little help in deploying the NAC . I am using the NAC in OOB Virtual Gateway mode.  I am facing a problem that i have made a check which check if KB910437 is available on the machine or not .If it is not it goes to microsoft site and downloa