Solved

startup class in websphere5.0

Posted on 2004-08-11
2
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

726 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