Solved

startup class in websphere5.0

Posted on 2004-08-11
2
173 Views
Last Modified: 2012-06-27
HI,
I need to provide email, when the websphere app.server starts first time. I would appreciate if anybody send me class file and how to do settings on application server.

thanks,
-Nati
0
Comment
Question by:prreddy
2 Comments
 
LVL 9

Expert Comment

by:nimaig
ID: 11780519
If you have your web application then the easy way to do is it
-- Write a class say SendMailAtStartUp.java which has public method say sendMail() which uses java mail api to send mail
-- Write a servlet.and 'make instance of the above class' and 'call the sendmail method()' in the init() method.
-- Register your servlet in web.xml.

Doing this, when the servlet is loaded by the web container for the first time, init() method would be invoked and the mail would be sent.
0
 
LVL 14

Accepted Solution

by:
boonleng earned 125 total points
ID: 11781280
Another way is to use add a ServletContextListener, this listener will execute when server startup and shutdown.

First extend the class ServletContextListener. example:

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class StartupServletContextListener implements ServletContextListener {
      
      /**
       * @see javax.servlet.ServletContextListener#contextInitialized(ServletContextEvent)
       */
      public void contextInitialized(ServletContextEvent arg0) {
        //put send mail function here.
      }

      /**
       * @see javax.servlet.ServletContextListener#contextDestroyed(ServletContextEvent)
       */
      public void contextDestroyed(ServletContextEvent arg0) {
      }
}


Then add the the listener class to the web.xml
<listener>
  <listener-class>com.something.StartupServletContextListener</listener-class>
</listener>
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now