Solved

startup class in websphere5.0

Posted on 2004-08-11
2
176 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

839 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