?
Solved

startup class in websphere5.0

Posted on 2004-08-11
2
Medium Priority
?
180 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 500 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

762 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