How can I generate a servlet on the fly?

View: New views
1 Messages — Rating Filter:   Alert me  

How can I generate a servlet on the fly?

by rigel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello, I'd like to know if it is possible with something like this code lines:
			HttpServlet hs = new HttpServlet(){
				@Override
				public void init() throws ServletException {
					super.init();
				}
				@Override
				public void destroy() {
					super.destroy();
				}
			};
The problem is that I am not able and I don't know how to register the new servlet into the host container and going on. Particularly I am interested to create a new servlet on the fly, and then accessing its ServletContext and so on from any Java class loaded into the container classpath. I know that a better approach it is to use JNDI or jsp:usebean for some shared configuration params, but I am particularly interested to understand how the servlet process works Thank you, bye