3 Replies Latest reply on Jan 10, 2006 7:48 PM by Elmo

    Emailing From ActionHandler

    toby saville Novice


      I am trying figure out how I can get a hold of objects from within action handlers.

      Specifically, I have an Email service singleton that is held in the application context of our Tomcat instance. I would like to use this service in the action handlers, but I cant think how to get a handle to it. The best way I have so far is to set it as a transient variable, but this means I would have to do this every time I retrieve the ProcessInstance from the database. This is possible, but it doesn?t seem very elegant.

      Are there any other suggestions?



        • 1. Re: Emailing From ActionHandler
          brittm Novice

          What about binding your e-mail class to JNDI and then doing a JNDI lookup in your action handler?


          • 2. Re: Emailing From ActionHandler
            toby saville Novice

            Thanks for your suggestion Britt, that is definitely a good option.

            How about if the email singleton is bound to our Spring WebApplicationContext, not to the tomcat ApplicationContext as previously stated, and I would prefer to retrieve it from here instead of from JNDI?

            Thanks again,


            • 3. Re: Emailing From ActionHandler
              Elmo Novice

              Hi Toby,

              If you dont have a solution yet and don't want to mess around with jndi, you can do this. In your servlet that creates or retrieves the process instance, get the handle of you mail service and place it in the context variable. Since variables are global to a process instance, you can already access that anywhere in your action handlers. Afterwards, remove the variable so it wont be saved in the database. (note: I tried transient variables but it doesn't seem to work, try normal variables instead)