Read config file only once for beans

I want to read onfiguration file Myconfig.cfg with many global values (server IP, port, database URL, pages, etc) I'm using a bean but every time a JSP or servlet create an instance of that bean all the data has to be read form disk...
I know that if I put the code for reading the file in the init() method in a servlet it is called only once, but how do I read those values from another servlet or JSP, ???
What is the best solution...

You can put initiation parameters in your web.xml file and write a servlet that is called on startup. Once the values are read you can put them into the application scope. (i.e. application.setAttribute("jdbcUrl", jdbcUr); )
Then in your JSP pages you can take them out by using the application.getAttribute("jdbcUrl"); method.

Similar Messages

  • Reading/processing file -- only once!

    Hi,
    I am working on a requirement that i have to open/read and process files that are continously created in one of the directories. Now i understand that i will have to make sure that the program does not process any file more than once.
    These files are being written into the directory at a very rapid rate, and my program has to read these files and insert the records in these dat files into the database. What would be the best approach to make sure that these files are not read/processed more than once?. Any pointers would be greatly appreciated.

    Hi,
    I am working on a requirement that i have to
    open/read and process files that are continously
    created in one of the directories. Now i understand
    that i will have to make sure that the program does
    not process any file more than once.
    These files are being written into the directory at a
    very rapid rate, and my program has to read these
    files and insert the records in these dat files into
    the database. What would be the best approach to make
    sure that these files are not read/processed more
    than once?. Any pointers would be greatly appreciated.Delete the file when you're done with it? Rename the file when you're done with it? Something like "my filename.processed.extension" or something. If neither of those are an option, you could create a List and add the processed files to the list. Check to see whether or not you have processed a file from the list - if not, then process it. But - if you are dealing with a lot of files, then the latter would be a horrible idea. (It would take up way too much time and resources as you continued to process files).

  • How to set a payload field value only once for multiple instances selected?

    The user needs to set a payload field value and then he can approve the task so the task can continue through the process, that's fine when the user selects one instance and sets the value in the task details section and then clicks the approve button, but how do we achieve the same behavior in a multiple way?, I mean the user can select multiple tasks in the workspace (in this case the details task page is not available and instead the following label appear "Multiple tasks selected") then if the user clicks the Actions drop down -> APPROVE he only gets the message "your request was processed successfully", so how can the user modify the payload field value only once for all the selected tasks so when he clicks APPROVE the value is populated in all the instances selected.
    Thanks,
    Carlos.

    In the action which displays the edit page just set the form idx value before displaying the jsp.

  • Is xmp files only availble for RAW files?

    When we develop a RAW image with Camera Raw, we always get an xmp file with all the settings,
    But after I developed a JPG image, I saw the Camera Raw Settings icon appeared above the right upper corner of the image thumbnail in Bridge,
    however, I couldn't find the xmp file.
    Is xmp files only availble for RAW files? JPGs or TIFs don't have xmp files for their Camera Raw settings??

    Read-only didn't work for me, on a single jpg file, although it did lead to some interesting behavior.  Set the read-only attribute on a jpg file in Windows XP and then tried the following:
    1.  Opened in Bridge, then into ACR 5.4.  Performed some edits, then tried "Done", received permissions error and would not save edits.
    2.  Did the same except now invoked "Open", went into CS4 with edits intact and allowed saving out as different file.  However, the ACR edits were not saved within the jpg, as expected, nor was a xmp created.
    3.  Removed the read-only attribute, repeated (2).  Even though did not save file in CS4 the "Open" action did embed the edits into the jpg.
    So read-only doesn't really allow creation of a xmp file, other than perhaps temporarily for transfer to Photoshop.  It does lead to somewhat inconsistent behavior, in that I would have expected the "Open" to fail also since it could not bury the edits in the jpg.
    Richard Southworth

  • Why java allow start() method only once for a thread

    Hi ,
    Why java allows start method only once for thread . suppose
    Thread t = new Thread();
    t.start();
    say at later stage if again we call t.start() IllegalStateException is thrown , even though isAlive method returns false.
    Hence the question , why start() method is allowed only once.If you need start a thread , we need to create a new instance.

    Really. Why do you think that? Do you have any evidence? It is one of the first things I would think of, personally.Considering that the Thread API doesn't allow you to specify a stack address (only stack size), I think it demonstrates they wanted to remove that capability from their Thread API all together. That missing "capability" makes me believe they want me to believe it's not something I need to worry about when using their API... I think the exact semantics of the Thread class and its methods were driven by how to make it most understandable and usable for their customers. I'm certain this issue was one of many that was given considerable thought during the design and implementation of the JVM and the underlying runtime classes.
    Do I have any evidence? No. But if you can point me at some first-hand information on this, I'd love to read it. Most of what I've found is second or third hand accounts. (and I mean that sincerely, not as a smart-ass remark or rebuke of your comments).
    On the one hand you seem to think the Java API designers are idiots, on the other hand you think that they should be. I can't make it out.I thought my position was that the Java developers were talented enough to implement platform in whatever way their API called for; hence, the designers made a choice about how they wanted their API to be used by their customers. They decided which capabilities they wanted to include or exclude, and created an API that was consistent with their vision for this technology. While I'm certain technical limitations had an effect on the API design, I certainly don't think the API was dictated by the them.
    I think the current design of the Java Thread API was a reflection of their vision to make Threading easier and more accessible to Joe Programmer, not limitations in the implementation. I never said it was wrong or that I could do better... I just said I think they could have done something different if they decided it would have made for a better customer experience. But hey, maybe I'm wrong.

  • Problem with reading config file

    Hello,
    I have problem with reading config file from the same dir as class is. Situation is:
    I have servlet which working with DB, and in confing file (config.pirms) are all info about connection (drivers, users, passw, etc.). Everything work fine if I hardcoded like:
    configFileName = "C:\\config.pirms";I need to avoid such hardcoding, I tryied to use:
    configFileName = Pirms.class.getClassLoader().getResourceAsStream ("/prj/config.pirms").toString();but it isn't work.
    My config file is in the same directory as Pirms.class (C:\apache-tomcat-5.5.17\webapps\ROOT\WEB-INF\classes\prj)
    Also I tryied BundledResources, it isn't work fo me also.
    Can anybody help me to solve this problem? with any examples or other stuff?
    Thanks in advance.
    Andrew

    Thanks, but I am getting error that "non-static method getServletConfig() cannot be referenced from a static context"
    Maybe is it possibility to use <init-param> into web.xml file like:
    <init-param>
      <param-name>configFile</param-name>
      <param-value>/prj/config.pirms</param-value>
    </init-param>If yes can anybody explain how to do that?
    I need to have that file for:
    FileReader readFile = new FileReader(configFile);Thanks in advance.

  • Need to display records only once for that particular group

    Hi,
    I have a requirement like displaying repeated records only once for that particular group.
    For eg, in the emp table, I need to display repeated deptno only once for the particular group of job.
    And for the above requirement I have used the below query,
    SELECT empno, DECODE (LAG (job, 1) OVER (ORDER BY job), job, NULL, job),
    DECODE (LAG (deptno, 1) OVER (ORDER BY deptno), deptno, NULL, deptno)
    FROM emp;
    Output:
    EMPNO     JOB     DEPTNO
    7782          10
    7934     CLERK     
    7839     PRESIDENT     
    7876          20
    7788          
    7902     ANALYST     
    7566     MANAGER     
    7844          30
    7900          
    7654     SALESMAN     
    7698          
    But in the above output you can find that, say deptno 10 is getting displayed only once, whereas I want that deptno 10 to be checked whether it is getting repeated within the group of JOB and than hide the deptno 10 only if it is repeated within that job group. If not, deptno 10 should be displayed again.
    Please help me in this.
    Regards,
    Shiva

    Hi,
    Hope the below helps.
    SELECT emp_id, job, deptno,
           CASE WHEN LAG(deptno, 1) OVER (partition by job order by deptno) = deptno THEN null else deptno end
      FROM empRegards
    Ameya

  • Help: I want to auto schedule a load using file watcher but it runs only once for the first time and after that it is not running at all

    Hi All,
    I am trying  to execute the below code as provided from one of the blogs. i am able to run the job only once based on a file watcher object(i.e. for very first time) and after that the job is not running at all and if  i schedule the job to run automatically based on interval of 10 or more minutes it is executing properly). Please let me know or guide me if i have missed any step or configuration.that is needed.
    Version of Oracle 11.2.0.1.0
    OS : Windows 7 Prof
    Given all the necessary privileges
    BEGIN
      DBMS_SCHEDULER.CREATE_CREDENTIAL(
         credential_name => 'cred',
         username        => 'XXXX',
         password        => 'XXXX');
    END;
    CREATE TABLE ZZZZ (WHEN timestamp, file_name varchar2(100),
       file_size number, processed char(1));
    CREATE OR REPLACE PROCEDURE YYYY
      (payload IN sys.scheduler_filewatcher_result) AS
    BEGIN
      INSERT INTO ZZZZ VALUES
         (payload.file_timestamp,
          payload.directory_path || '/' || payload.actual_file_name,
          payload.file_size,
          'N');
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_PROGRAM(
        program_name        => 'prog1',
        program_type        => 'stored_procedure',
        program_action      => 'YYYY',
        number_of_arguments => 1,
        enabled             => FALSE);
      DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT(
        program_name        => 'prog1',
        metadata_attribute  => 'event_message',
        argument_position   => 1);
      DBMS_SCHEDULER.ENABLE('prog1');
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_FILE_WATCHER(
        file_watcher_name => 'file_watcher1',
        directory_path    => 'D:\AAAA',
        file_name         => '*.txt',
        credential_name   => 'cred',
        destination       => NULL,
        enabled           => FALSE);
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_JOB(
        job_name        => 'job1',
        program_name    => 'prog1',
        queue_spec      => 'file_watcher1',
        auto_drop       => FALSE,
        enabled         => FALSE);
      DBMS_SCHEDULER.SET_ATTRIBUTE('job1','PARALLEL_INSTANCES',TRUE);
    END;
    EXEC DBMS_SCHEDULER.ENABLE('file_watcher1,job1');
    Regards,
    kumar.

    Please post a copy and paste of a complete run of a test case, similar to what I have shown below.
    SCOTT@orcl12c> SELECT banner FROM v$version
      2  /
    BANNER
    Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
    PL/SQL Release 12.1.0.1.0 - Production
    CORE    12.1.0.1.0    Production
    TNS for 64-bit Windows: Version 12.1.0.1.0 - Production
    NLSRTL Version 12.1.0.1.0 - Production
    5 rows selected.
    SCOTT@orcl12c> CONN / AS SYSDBA
    Connected.
    SYS@orcl12c> -- set file watcher interval to one minute:
    SYS@orcl12c> BEGIN
      2    DBMS_SCHEDULER.SET_ATTRIBUTE
      3       ('file_watcher_schedule',
      4        'repeat_interval',
      5        'freq=minutely; interval=1');
      6  END;
      7  /
    PL/SQL procedure successfully completed.
    SYS@orcl12c> CONNECT scott/tiger
    Connected.
    SCOTT@orcl12c> BEGIN
      2    -- create credential using operating system user and password (fill in your own):
      3    DBMS_SCHEDULER.CREATE_CREDENTIAL
      4       (credential_name     => 'cred',
      5        username          => '...',
      6        password          => '...');
      7  END;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- create table to insert results into:
    SCOTT@orcl12c> CREATE TABLE ZZZZ
      2    (WHEN      timestamp,
      3      file_name varchar2(100),
      4      file_size number,
      5      processed char(1))
      6  /
    Table created.
    SCOTT@orcl12c> -- create procedure to insert results:
    SCOTT@orcl12c> CREATE OR REPLACE PROCEDURE YYYY
      2    (payload IN sys.scheduler_filewatcher_result)
      3  AS
      4  BEGIN
      5    INSERT INTO ZZZZ VALUES
      6        (payload.file_timestamp,
      7         payload.directory_path || '/' || payload.actual_file_name,
      8         payload.file_size,
      9         'N');
    10  END;
    11  /
    Procedure created.
    SCOTT@orcl12c> -- create program, define metadata, and enable:
    SCOTT@orcl12c> BEGIN
      2    DBMS_SCHEDULER.CREATE_PROGRAM
      3       (program_name          => 'prog1',
      4        program_type          => 'stored_procedure',
      5        program_action      => 'YYYY',
      6        number_of_arguments => 1,
      7        enabled          => FALSE);
      8    DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT(
      9       program_name         => 'prog1',
    10       metadata_attribute  => 'event_message',
    11       argument_position   => 1);
    12    DBMS_SCHEDULER.ENABLE ('prog1');
    13  END;
    14  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> BEGIN
      2    -- create file watcher:
      3    DBMS_SCHEDULER.CREATE_FILE_WATCHER
      4       (file_watcher_name   => 'file_watcher1',
      5        directory_path      => 'c:\my_oracle_files',
      6        file_name          => 'f*.txt',
      7        credential_name     => 'cred',
      8        destination          => NULL,
      9        enabled          => FALSE);
    10  END;
    11  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> BEGIN
      2    -- create job:
      3    DBMS_SCHEDULER.CREATE_JOB
      4       (job_name          => 'job1',
      5        program_name          => 'prog1',
      6        queue_spec          => 'file_watcher1',
      7        auto_drop          => FALSE,
      8        enabled          => FALSE);
      9    -- set attributes:
    10    DBMS_SCHEDULER.SET_ATTRIBUTE ('job1', 'PARALLEL_INSTANCES', TRUE);
    11  END;
    12  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- enable:
    SCOTT@orcl12c> EXEC DBMS_SCHEDULER.enable ('file_watcher1, job1');
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- write file (file must not exist previously):
    SCOTT@orcl12c> CREATE OR REPLACE DIRECTORY upncommon_dir AS 'c:\my_oracle_files'
      2  /
    Directory created.
    SCOTT@orcl12c> declare
      2    filtyp utl_file.file_type;
      3  begin
      4    filtyp := utl_file.fopen ('UPNCOMMON_DIR', 'file1.txt', 'W', NULL);
      5    utl_file.put_line (filtyp, 'File has arrived ' || SYSTIMESTAMP, TRUE);
      6    utl_file.fclose (filtyp);
      7  end;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- wait long enough (may take more than one minute) for job to run:
    SCOTT@orcl12c> EXEC DBMS_LOCK.SLEEP (100)
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- check for results:
    SCOTT@orcl12c> SELECT * FROM zzzz
      2  /
    WHEN
    FILE_NAME
    FILE_SIZE P
    22-OCT-13 10.12.28.309000 PM
    c:\my_oracle_files/file1.txt
            57 N
    1 row selected.
    SCOTT@orcl12c> declare
      2    filtyp utl_file.file_type;
      3  begin
      4    filtyp := utl_file.fopen ('UPNCOMMON_DIR', 'file2.txt', 'W', NULL);
      5    utl_file.put_line (filtyp, 'File has arrived ' || SYSTIMESTAMP, TRUE);
      6    utl_file.fclose (filtyp);
      7  end;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- wait long enough (may take more than one minute) for job to run:
    SCOTT@orcl12c> EXEC DBMS_LOCK.SLEEP (100)
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- check for results:
    SCOTT@orcl12c> SELECT * FROM zzzz
      2  /
    WHEN
    FILE_NAME
    FILE_SIZE P
    22-OCT-13 10.12.28.309000 PM
    c:\my_oracle_files/file1.txt
            57 N
    22-OCT-13 10.14.08.580000 PM
    c:\my_oracle_files/file2.txt
            57 N
    2 rows selected.

  • Need to populate value for a KF only once for a combination of characterist

    Hello All,
    We had a requirement for a report. wherein we need to consolidate the data of the 0FI_GL_4 datasource and a custom table.
    both these sources have only 4 fields in common i.e Fiscal Year/Period; Company Code and Pool
    in the custom table, for each fiscal yr/period & Pool combination, there is a unique Plan value available.
    To consolidate the data, I wrote a routine in the transformation to extract data from the custom table based n the combination of Fisc yr Period, Comp Code & Pool.
    However, since 0FI_GL_4 has more than 1 entry for the above mentioned combination  that is GL_accounts, document number, etc; during extraction, my plan value is being extracted multiple times to the cube and hence for a fiscal yr/period, cube shows a summation value.
    I want the plan value to be picked only once.. please advice

    Hi Sneha,
    As I understand in your infocube along with the primary key of custom table one more field exists e.g. Document number and due to which the value is getting repeated over multiple lines.
    Though all these records are valid but when you are running report on this cube without document number all the plan values are getting aggregated, again this behaviour is also correct.
    For your reporting purpost I feel that you need to extract data from the custom table in other data target and then do the reporting on that, wherein the plan value will not be repeated.
    Regards,
    Durgesh.

  • Adding list based menu only once for all related pages

    Hi,
    I have a one level tab application. For a given tab I have 5 different pages. I would like let the end user navigate to these pages via a list region. Currently I have added to all five pages a list region and assigned the same list item to these list regions.
    Is it possible that I add this list based menu only once to my application or this is the normal way of doing it?
    Is there a way to let
    Regards,
    Tamas

    Use page zero.
    Add regions containing the lists for each tab to the same region display point on page zero, making each region conditional using a "Current Page Is Contained Within Expression 1..." condition.

  • Why only once for create recovery media???

    When I created recovery discs for my laptop using HP Recovery Manager, I got the message:
      You can only create recovery media once for your system. So ensure that you keep it in a safe place
    why only once?? what is the problem with creating the same discs again?
    what is the difference when creating the recovery discs with the Backup and Restore utils in Windows 7? is it also once only? what is the difference between discs created with Windows 7 versus HP Recovery Manager?

    I believe it is due to MS license agreement that only 1 set is allowed. You can of course use a CD/DVD burning program to copy the set you made.
    The Recovery set you burn restores the laptop back to factory shipped state. Recovery made with Win 7 utility is an image of the hdd that includes added programs, data ,photos,etc.You also need to burn the System repair disc to use with the backup. You can use it as often as you like.
    ******Clicking the Thumbs-Up button is a way to say -Thanks!.******
    **Click Accept as Solution on a Reply that solves your issue to help others**

  • Airport Express - cannot read config file - cannot Hard reset

    Anyone, please help!
    I have an Airport Express as an 'add to an existing network' connected to the UFO Base Station (White). The internet connection is fine, but I cannot read the config file to access the wireless printer part. I have tried to reset the express - it resets it goes green still no read. I have tried to hard reset this back to the factory settings. Same thing, it thinks about it then everything is back green, same as before and I still cannot read the config. I will add that I have had to reset or hard reset or mess with this once a week since I got this. Is there anything else I can try. I have nothing connected to the express everything is wireless. Please I do know how to do a hard reset, its just not accepting the command.
    Anyone, please....

    Are you sure it's not alternating amber/green? I have seen it, it's hard to tell, if you are color blind
    , it's even harder.
    http://docs.info.apple.com/article.html?artnum=108045

  • Running a query only once for a report in Reports 6i in a BEFORE REPORT trigger.

    Hello all -
    I am using Oracle Reports 6i on Windows NT 4.0 SP 6.0.
    The report I am converting from Access to Oracle Reports is
    rather complex, and features detail by decile (a rank) within
    territory (geographical sales area). Also it features a summary
    at the bottom of each territory/decile combination which
    summarizes not only the territory information, but goes above
    that to higher levels like district, region, and national.
    With the help of a consultant, we have managed to get the report
    almost finished. However, we are running into a snag with the
    summary. While my two main queries need to run in the data
    model as normal, I would like to run the summary query _only
    once_ during the entire cycle of the report, and have the report
    fields populated once for the entire report. This is possible
    because for a district, the summary numbers are the same on
    every page of the report, only the territory information
    changes. So by only having the query run once and fill the
    report values once, this would save considerably on the report
    runtime.
    However, I have tried a few different methods but cannot get the
    report to recognize the fields in the query, most likely because
    they are out of scope at report creation. Does anyone have any
    ideas on how I can accomplish this in Reports? Any help would
    be appreciated - I hope my question was clear, if not please let
    me know.
    Thanks,
    -Jennifer Prichard

    Hello!
    You can place in the data model editor formula and placeholder
    columns outside of any groups. I think you need for each of your
    summary-attibutes a placeholder column and one formula column.
    Use the formula column to populate the placeholders via PL/SQL.
    Afterwords you can reference the placeholders anywhere you want.
    Regards,
    Hajo Winkler

  • Mass activity running only once for custom parallel object

    Hi
    I have created custom parallel object EXT_UI and created mass activity for this but the report in triggered only once and not going for second interval .
    Can any one help me out in this.
    Thanks in advance.
    Chetan
    Message was edited by: CHETAN N P
    Mass activity is running fine for standard object ANLAGE but not for custom one
    Please share me steps to be followed in creating custom parallel object.
    Regards,
    Chetan

    Hi Chetan,
    I think you need to make changes in the Events which gets triggered by the mass activity.
    Can you let me know the mass transaction code for which you have customised the activity,
    Thanks,
    Amlan

  • Asking only once for a parameter...

    Post Author: Nightcrawler
    CA Forum: Data Connectivity and SQL
    Hi,
    I have a report which need to select a list of items for a dynamic lookup for the report. I have created two stored procedure in SQL which work in QA. When I link them to a report I get asked for the date range twice. This is because the two stored procedures ask for the date range for them to select data. The parameter names are the same in each stored procedure. Basically I want the screen to ask me for the date range then give me a popup list based on the items. Then pass this to the second stored procedure to run for the report ??
    How is best to do this ?
    Thanks
    Ed

    Post Author: Nightcrawler
    CA Forum: Data Connectivity and SQL
    Hi,
    No there are no refs in the section expert. Not sure what you mean by in and out but ? The date is passed to the sp but not returned.
    It seems everytime I want to do a dynamic pararmeters for the first sp. It asks me for the varaibles but not the ones listed in field explorer.... IE if I link the field explorer fields for the first sp to the subreport it asks for the date twice ?? Once for the first sp ( I can tell this as it has the name of one of the sp fields in the top right of each question) and then again for the paremeters that are in the field explorer - which I have given a description, thus I can tell there the next set.
    Surely thou these first parameters are the same ?? Is there a way of changing the priority...
    It seems a complex system for something that should be very simple.
    All I want is to pass two date values to have a dynamic list of rooms wchih are valid. Then pass the same date variable and the chosen room to the next sp... but prefrable without the duplicate date asking .....
    I've just read the subreport linking docs but its doesnt help as everytime you refernace the parameters from the first sp that are shown in field explorer, it asks duplicate questions.
    Just to make this clearer - when I say duplicate questions I mean it is obiviously runs the sp first then for those variables. Then it runs the report and asks for the field explorer variables which it has created when I first referanced the sp. Does this make sense ???
    Thanks
    Ed

Maybe you are looking for

  • Long file names-won't copy

    how can i turn off my macs irritating annoyance at not wanting to copy files with long file names ? some of these files come straight from CD's, so I can't change the filenames unless I went to a PC, copied them, changed the name and then copied them

  • Mic problems

    My HP Windows 8 computer mic isn't working. Help ASAP please, I have to make a Skype call for work.

  • H-REAP Mode

    Hi, Does anyone know the limitations or guidance for large H-REAP deployments. Any Cisco documents on Cisco's recommended quantity of access points per remote site using H-Reap mode in either central or local switching instances, H-group limits, depl

  • "Flash out of date" comes up, new install, and will not accept Password for install?  Next step?

    "Flash out of date" comes up, i do a new install, the log-in and password windows pops up, I type in password and it will not accept. I have changed password, confirmed password, rebooted several times, and it still will not re-insall new version. I

  • How to configure output device option

    DEAR ALL ,                   I have been facing problem in taking printout in line printer(lp04)  with page dimension 305 mm * 215mm for transaction mb90--> output type -->we03 which is not giving the option to choose output device type before print