Создали EAR архив с модулем Dinamic WebProject
package ru.javalabs;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(urlPatterns="/s1", loadOnStartup=10)
public class S1 extends HttpServlet {
private static final long serialVersionUID = 1L;
public S1() {
super();
}
private long id;
@Override
public void destroy() {
System.out.println("---- Servlet id=" + id + "created");
super.destroy();
}
@Override
public void init() throws ServletException {
super.init();
id = System.currentTimeMillis();
System.out.println("---- Servlet id=" + id + "created");
}
}