I have a Java program/thread that I want to deploy into an Application Server (GlassFish). The thread should run as a \"service\" that starts when the Application Server starts
Create a servlet whose init method starts a thread which is the main program.
public void init() throws ServletException {
mailThread = new MailSendThread();
mailThread.start();
}
In our application's web.xml file add a servlet that includes a load-on-startup element where the number is the order in which it starts.
Mail Sending Servlet
MailServlet
2