How to schedule events using ServletContextListener??

Hello all
I have a servlet which contains a hashtable. I need to update it every hour with some new entries. I have read some of the other threads which suggest one to implement a ServletContextListener, and when the servletcontext is created or destroyed, certain methods would be called. So can I have my servlet implement ServletContextListener and write methods to do the same? When is the servletcontext created or destroyed?? Can I do it every hourly??
Please help me with suggestions and any example code would be great.
thanks a lot
Mahesh :)

in servlet specification 2.3 I found
Servlet Context Events
Lifecycle: The servlet context has just been created and is available to service its first request, or the servlet context is about to be shut down
An Example of Listener Use:
To illustrate a use of the event scheme, consider a simple web application containing
a number of servlets that make use of a database. The developer has provided a
servlet context listener class for management of the database connection.
1. When the application starts up, the listener class is notified. The application
logs on to the database, and stores the connection in the servlet context.
2. Servlets in the application access the connection as needed during activity in
the web application.
3. When the web server is shut down, or the application is removed from the web
server, the listener class is notified and the database connection is closed.
ServletContext created when application deployed or server started
ServletContext destroyed when for example server was shut down

Similar Messages

  • How to schedule jobs using

    Hello Gurus,
    I have a job in SM37 scheduled using the prog. RSBATCH1 with var.&0000000000049. When I go to SE38, give the program name and the var and execute it, there is nothing entered in the 'Jobname' in the user selection screen.
    But when it is executed it runs two(2) Infopackages for that variant.
    I want to remove one of the infopackages. How do I achieve this?
    Where can I get more info on how to schedule jobs using
    RSBATCH1.
    Thanks in advance
    Simmi

    Hi Simmi,
    If the variant is like "var.&0000000000049" in  the job then the program does not ahve any variant.
    To remove the infoapckage for that job goto the infoapckage -> scheduling tab -> Scheduling option -> remove the job from "after job" tab.
    Bye
    Dinesh

  • How to Schedule Job using Database Control for SQLPLUS script?

    Hi All,
    I am using Database version 10.2. I would like to schedule a SQLPLUS script job using Database control (Not using Grid Control!). The following is the script.
    ========================================================
    define OEM_FRIENDLY=1
    define OWB_BACKGROUND=0
    set serveroutput on
    set verify off
    whenever sqlerror exit failure;
    define REPOS_OWNER='&1.'
    define LOCATION_NAME='&2.'
    define TASK_TYPE='&3.'
    define TASK_NAME='&4.'
    define SYSTEM_PARAMS='&5.'
    define CUSTOM_PARAMS='&6.'
    alter session set current_schema = &REPOS_OWNER.;
    set role owb_d_&REPOS_OWNER., owb_o_&REPOS_OWNER.;
    variable exec_return_code number;
    begin
    -- Initialize Return Code
    :exec_return_code := wb_rt_api_exec.RESULT_FAILURE;
    -- Run Task
    :exec_return_code := wb_rt_api_exec.run_task('&LOCATION_NAME.',
    '&TASK_TYPE.',
    '&TASK_NAME.',
    '&CUSTOM_PARAMS.',
    '&SYSTEM_PARAMS.',
    &OEM_FRIENDLY.,
    &OWB_BACKGROUND.);
    end;
    exit :exec_return_code;
    ===========================================================
    Is it possible to schedule SQLPLUS script with 6 different parameters? If yes then how can I schedule for monday to friday or only for Saturday and sundays.
    Please provide brief steps.
    Thanks for your help in advance.
    - Mehul

    Let me explain to you about scheduler.
    You can schedule a pl/sql stored procedure TEST_S as follows...
    Begin
    dbms_scheduler.create_job(
    job_name=>'MY_JOB',
    Job_Type=>'STORED_PROCEDURE',
    job_action=>'TEST_S',
    start_date=>sysdate,
    repeat_interval=>'freq=monthly;BYDAY=MON,TUE,WED,THU,FRI',
    end_date=>null');
    END;
    You can also also execute o/s script like .bat or .sh. For this job type should be EXECUTABLE.
    Example of converting a .sql script in .bat script...
    insert.sql
    insert into dept values(50,'IT','LONDON');
    exit
    insert.bat
    sqlplus scott/tiger @insert.sql
    Executing now...
    C:\Documents and Settings>insert.bat
    C:\Documents and Settings>sqlplus scott/tiger @insert.sql
    SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 1 08:01:00 2007
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    1 row created.
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - P
    oduction
    With the Partitioning, OLAP and Data Mining options
    C:\Documents and Settings>
    So first read about DBMS_SCHEDULER and do the work in prompt. Then you can go and schedule it even by database control.
    Scheduling by database control...
    http://www.oracle.com/technology/oramag/oracle/04-jul/o44tech_dba.html
    Scheduler
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#CIHEHDHA
    PS: By default each job you created is disable state. Please enable it by enable procedure of DBMS_SCHEDULER package.

  • How to Bubble Event  use in SAP??

    Hi all ,
         I have a UDO Addon .I used  one more validation for user fields value in Add /Update as i return  False for validation .B1 bubble Checker  show error for return false.B1 bubble checker not show error with bubble value false for Item add validation .Any one help how to SAP maintain Bubble event for validation but B1 bubble Checker not  showing bubble event false .
    thanks
    surajit

    Hi
    You can bypass that message using the following code , also use message box instead of status bar in form data event ...
    Public Overrides Sub OnStatusBarErrorMessage(ByVal txt As String)
                'ADD YOUR CODE HERE     ...
                Try
                    If txt.Contains("UI_API -7780") Then B1Connections.theAppl.StatusBar.SetText("", 0, BoStatusBarMessageType.smt_None)
                Catch ex As Exception
                End Try
            End Sub
    Refer these threads for more information
    "Action stopped by add-on (UI_API -7780) Message 66000-152"
    Re: Action Stoped by Add-ON
    Re: UDO - How to handle an scenario
    DATA ADD EVENT
    Re: B1DE and screen validation ..
    Re: Validation in Form Data add Event
    Displaying message when canceling event
    Hope this helps
    Arun

  • How to schedule imports using MDIS

    Dear MDM experts,
    Pls let me know if there is a way to schedule MDIS for imports rather than have it do it  24/7,e.g. need MDIS to work only at 6 pm everyday.
    Pls let me know what parametr influences that.
    Thanks.
    Ashish

    Hi Ashish,
    As per my understanding there is no need to create any scheduled tasks for MDIS import because even if u do so then u need to keep the MDIS in stopped mode.
    If the MDIS is not in stopped mode then even if u schedule any MDIS import task at 6.00 am it will only run the MDIS but it wont find any files to import coz whenever u place any file in the inbound port it gets sucked instantly.
    So for this scheduled task to run MDIS shud be in stopped mode or else it will import the file instantly.
    Try creating a scheduled task to start the services of MDIS if this is possible then whatever files that are present inbound port MDIS will import.
    But I dont think it is possible to schedule to start the services.
    Hope dis helps u
    Regards Tejas.....
    Edited by: Tejas Bane on Feb 4, 2008 11:31 AM

  • How to schedule restart of Workflow notification mailer?

    We are facing this issue in all environments including production;
    Inbound IMAP Notification emails are pending in the INBOX folder of the mail box. These moves to PROCESS folder only after restart of the 'WORKFLOW NOTIFICATION MAILER' every 3 to 4 hours.
    I have raised an SR with Oracle support for a solution.
    For this temporary workaround of restarting the Notificaiton mailer, I want to know how can I schedule the automatic restart of the 'WORKFLOW NOTIFICATION MAILER', Please advice.

    Sami,
    See (Note: 466927.1 - How to Schedule Events for the Workflow Notification Mailer).
    Regards,
    Hussein

  • How to schedule a background Job based on events

    Hi,
    We are on 4.6 C.
    We have a background job that has two ABAP programs.
    We need to start the 2nd ABAP program only after the first one has run successfully.
    If the second ABAP program does not run, the the job should have a status "FINISHED".
    Help appreciated.
    Thanks
    Mala

    Hi,
    How to schedule a background Job based on events,please refer to the follow SAP help:
    You can use events that have already been defined, or you can create new events for scheduling background jobs.
    If you wish to use new events, do the following to implement the event scheduling:
    Define and transport the event as a user event with transaction SM62.
    You must define only event IDs; event arguments are not defined in the R/3 System. Instead, you specify event arguments when you schedule a job to wait for an event and when you trigger the event.
    If you define a new event, you must also transport it to your production systems. The event transaction does not have a connection to the transport system. Instead, you must create a transport request for the event yourself.
    Do this to transport an event:
    Create a transport request.
    Start the editor in the transport request and enter the following:
    R3TR TABU <table name> where table name is BTCSEV for a system event ID, BTCUEV for a user event ID.
    Press F2 with the cursor on the table name to call up the screen for specifying the table entries to transport. In this screen, enter the event ID’s that you have created.
    Save and release the transport request. Ensure that it is imported into your production system(s).
    To trigger an event, add:
    – the function module BP_EVENT_RAISE to your ABAP program, or
    – the program SAPEVT to your external script, batch file, or program.
    When your programs execute these keywords, an event will be triggered in the R/3 background processing system. The event-based scheduler is started immediately. It in turn starts all jobs that were waiting upon the event, subject to normal background processing restrictions, such as the requirement that the job has been released to start.
    Schedule the jobs that are to run when your events are triggered.
    You can schedule jobs for one-time start or to be started whenever an event is triggered.
    Regards,
    collysun

  • How to Raise Event in BW using ABAP program

    Hi BW Experts,
    Can anyone tell how to raise event in BW using a ABAP program.
    Program should ask for the event to be raised and destination server.
    Edited by: Arun Purohit on May 14, 2008 11:04 AM

    Hi Arun,
    By Using BP_EVENT_RAISE function module you can raise an event.Create an ABAP program and call the function module BP_EVENT_RAISE and create a avariant to specify the event to be raised. Schedule this ABAP code. Go to the start process type and set the schedule to "after event" and mention the event name that you created. Also, I think now you can mention the time as well and you can also schedule for periodic scheduling.
    T Code : SM62 --> To Create an Event.
    T Code : SE38 --> To Create an ABAP Program
    Use Function Module : BP_EVENT_RAISE to raise an event.
    Related links:
    http://help.sap.com/saphelp_sem40bw/helpdata/EN/86/6ff03b166c8d66e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_sem40bw/helpdata/EN/86/6ff03b166c8d66e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_sem40bw/helpdata/EN/86/6ff03b166c8d66e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_sem40bw/helpdata/EN/86/6ff03b166c8d66e10000000a11402f/frameset
    Hope this helps
    Regards
    CSM Reddy

  • TS3999 how to see list of all scheduled events in calendar

    Every now and then I can't seem to find the list of all events scheduled on calendar.  Only those for a particular day. How see all events?

    I understand exactly what edwardfromma is talking about. He wants a simple chronological list of ALL events in calendar NOT in the context of the calendar view. This is a very useful feature that almost every other calendar app has. Usability of Apple IOS seems to be degrading.

  • How to implemented an scheduled service using ScheduledExecutorService

    Hi, everybody
    I have a case that need retrieve data periodically from server. And I used the ScheduledExecutorService and javafx.concurrent.Service to implemented this case. But the trick thing is that ScheduledExecutorService schedule method aleady need a Runnable parameter. And Service setExecutor method set the ScheduledExecutorService. But the result is the Runnable is implemented run periodically but not the Service's call method(Which is I want). The Service is not extends from Runnable or Callable, how it can be used by the ScheduledExecutorService to implemented the periodical task?
    Please see my example:
    public class ScheduledService extends Application{
         * @param args
         *            the command line arguments
        public static void main(String[] args) {
            launch(args);
        @Override
        public void start(Stage primaryStage) throws Exception {
            primaryStage.setTitle("Test");
            Parent root = new Label("abc");
            Scene scene = new Scene(root, 800, 600);
            primaryStage.setScene(scene);
            primaryStage.show();
            test();
        public static void test() {
            ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
            scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
                @Override
                public void run() {
                    System.out.println("ScheduledServiceTest.main(...).new Runnable() {...}.run()");
            }, 0, 2, TimeUnit.SECONDS);
            CustomService service = new CustomService();
            service.setExecutor(scheduledExecutorService);
            service.start();
    class CustomService extends Service<Void> {
        @Override
        protected Task<Void> createTask() {
            return new Task<Void>() {
                @Override
                protected Void call() throws Exception {
                    System.out.println("CustomService.createTask().new Task() {...}.call()");
                    return null;
    }The result is:
    ScheduledServiceTest.main(...).new Runnable() {...}.run()
    CustomService.createTask().new Task() {...}.call()
    ScheduledServiceTest.main(...).new Runnable() {...}.run()
    ScheduledServiceTest.main(...).new Runnable() {...}.run()
    ScheduledServiceTest.main(...).new Runnable() {...}.run()
    ScheduledServiceTest.main(...).new Runnable() {...}.run()
    ScheduledServiceTest.main(...).new Runnable() {...}.run()
    {code}
    Edited by: Owen on May 20, 2012 12:05 AM
    Edited by: Owen on May 20, 2012 12:07 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    You are not allowed to call "restart" on a different thread, it must be from the JavaFX application thread. You don't see the Exception for it because it is encapsulated in the ScheduledFuture that "executor.scheduleWithFixedDelay" returns.
    Let's forget about this ScheduledExecutorService, that is not the way to do it when you want to work with a Service. Here's a fully working example that uses standard JavaFX:
    package hs.mediasystem;
    import javafx.animation.Animation;
    import javafx.animation.KeyFrame;
    import javafx.animation.Timeline;
    import javafx.application.Application;
    import javafx.concurrent.Service;
    import javafx.concurrent.Task;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.stage.Stage;
    import javafx.util.Duration;
    public class Test extends Application {
      public static void main(String[] args) {
        launch(args);
      public static class MyService extends Service<Void> {
        @Override
        protected Task<Void> createTask() {
          return new Task<Void>() {
            @Override
            protected Void call() throws Exception {
              System.out.println("Begin task");
              return null;
      @Override
      public void start(Stage paramStage) throws Exception {
        final MyService myService = new MyService();
        Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(5), new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            myService.restart();   // automatically on JavaFX thread, so can call restart directly
        timeline.setCycleCount(Animation.INDEFINITE);
        timeline.playFrom("end"); // can also play from start but you will have an initial 5 second delay
    }

  • How to schedule job to execute after 5 seconds gap using the program

    Hi ALL,
    How to schedule the program to run after 5 seconds to execute using JOB_OPEN,JOB_CLOSE,SUB_SUBMIT function modules in which parameter I should give this 5 secnods?
    Regards
    mahesh

    Hi,
    You can use the import parameters of function module JOB_CLOSE
    SDLSTRTDT & SDLSTRTTM
    to pass the required start date and time (respectively) of your background job. That is, if you want the job to be scheduled and start at a fixed time (as in your case 5 seconds in the future), you can determine the start date and time as 5 seconds ahead of sy-uzeit and pass the resultant values to the mentioned importing parameters.
    Cheers,
    Aditya

  • How to schedule the background job using current selection screen field val

    Hello Friends,
    How to schedule the background job using current selection screen field values.
    after completion of the job the spool should be sent as a mail to SAP Inbox.
    Is there any way to create the variant dynamically by reading the current selection screen values.
    Thanks,
    Ravi

    Hi,
    To get the variant details you can use teh following FM.
    'RS_VARIANT_CONTENTS'.
    Regards,
    Ankur Parab

  • How to Disable Event firing while updating a list item using poweshell

    Hi All,
    I am working on a powershell code which updates most of the list items in the entire web application. I am using SystemUpdate($false) to update the items so that 'modified' and 'modified By' and versions are not changed.
    However event receivers gets fired which is now a problem. I want to disable the Event receivers before update and enable it after update. I want powershell code for this. I am using SharePoint 2010.
    Your help would be much appreciated. Thank you in anticipation.
    Regards
    Karthik R.

    hi
    check this thread:
    How to disable event firing outside an event. It contains example on C#, but it is not difficult to convert it to PowerShell.
    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

  • HOW TO CREATE  and  USE EVENTS IN WORKFLOWS .

    HOW TO CREATE  and  USE EVENTS IN WORKFLOWS with the help of classes.
    What i am doing is..
    open se24
    event tab->event name->parameters
    method tab->method name->event handler->copy parameters
    interface tab->if_workflow->enter
    tell me what else to do step by step
    Another important thing is that HOW to use these class events to trigger the workflows.
    REPLY ASAP
    THXS IN ADVANCE

    Hi,
    Pl. see this blog...
    Raising ABAP OO events for workflow
    Regards,
    JOy.

  • How to Access Custom Event using AS3?

    Hi All,
    Maybe it's that its Monday morning and my brain is still foggy, but I can't seem to figure out how to set custom events using AS3.
    I have a custom GridRow itemRenderer, and have declared the event using the appropriate metatags.
    Then I create the GR item dynamically using AS3 instantiation, but the event is not available for selection in the intellisense drop-down.
    Let's take the following as an example:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Grid
         xmlns:mx="http://www.adobe.com/2006/mxml"
         xmlns:renderers="com.brassworks.renderers.*"
         creationComplete="componentInit();"
    >
         <mx:Script>
              <![CDATA[
                   private function componentInit():void
                        newRow     :MyRow     = new MyRow();
                        //newRow.myEvent is not an available option to set
              ]]>
         </mx:Script>
    </mx:Grid>
    Then the itemRenderer:
    <?xml version="1.0" encoding="utf-8"?>
    <GridRow
         xmlns:mx="http://www.adobe.com/2006/mxml"
         xmlns:classes="com.brassworks.components.classes.*"
         creationComplete="componentInit();"
    >
         <mx:Metadata>
              [Event(name="myEvent", type="flash.events.Event")]
         </mx:Metadata>
         <mx:Script>
              <![CDATA[
                   private function itemChanged(event:Event):void
                   Alert.show("test");
                   this.dispatchEvent(new Event("myEvent"));
              ]]>
         </mx:Script>
         <mx:GridItem>
              <mx:TextInput
                   change="itemChanged"
              />
         </mx:GridItem>
    </GridRow>
    How do I go about setting the handler method for custom events on instantiated items? Do I need to do this via the AddEventListener() method? Does this mean that events aren't exposed in ActionScript like they are in MXML? (In MXML all I have to do is <MyRow myEvent="handler(event)" />.)
    Thanks!
    -Mike

    Yes, I you need to do this via the addEventListener() method.
    myRow.addEventListener( "myEvent", myHandler );
    I hope that helps.
    Ben Edwards

Maybe you are looking for

  • How do you post a Browser Recommendation on an iWeb '08 page?

    Several years back, many websites used to have a "+Best if Viewed With+" and name a preferred browser. While we wait for improved compatibility for iWeb with other browsers (namely PC IE), I was thinking of adding that tag with a link to the Mac and

  • After ntrans-j2ee, matching ppath objects are ignored

    Aa of WS7.0u2, I'm seeing that ppath objects that should match are being ignored whenever an explicit JSP file is specified, but not for any other type. This is different from WS7.0u1 and earlier. In earlier versions, the ppath object always matched,

  • Problems with prepared statement in MYSQL.

    I 've this code: String sql = "UPDATE dcr SET Fecha=?, Origen=?, Destino=?, Mensaje=?, Estado=? WHERE IDDCR=? AND IDUsuario=?"; PreparedStatement st = cn.prepareStatement(sql); SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); java.sql.Date

  • Domain Functional Level: 2008 R2 to 2012 R2

    My current forest and domain functional levels are 2008 R2. I know I can safely upgrade the functional levels in most cases, but I want to specifically know with regards to Lync. Our entire environment, including Lync, is running on Windows Server 20

  • FCP X crashing - a lot in Mountain Lion

    Hi all - I hve recently bought FCP X after a trial which went very smoothly. Since buying and upgrading, FCP Xhas become VERY unstable. It usually crashes on open at least every other time and often hangs when in use. Do people have similar problems