| Author |
A couple of init() questions...
|
James Hodgkiss
Ranch Hand
Joined: Jan 22, 2004
Posts: 401
|
|
Hello, In my init() method, I want a loop that loops forever ( while(true){... ). Can I do this in the init() method? Do I just do it in a new thread? Also, what is the purpose of the super.init(config) line? What happens if I leave it in? What happens if I leave it out? Thanks, James
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Something like that should be in another thread. Kicked off in a context listener. You should also make sure you have a solid way of killing this thread from the contextDestroyed method of your listener or make sure you are using daemon threads. Otherwise, you may have trouble reloading your app and/or stopping and restarting you server. I generally advise against starting your own threads in a webapp unless, you really know what you're doing and can't find any alternative. Mind sharing what you are using the loop for? -Ben
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
James Hodgkiss
Ranch Hand
Joined: Jan 22, 2004
Posts: 401
|
|
Hiya Ben, Thanks for the reply. It's to constantly re-read a dynamic web page, from which the servlet is taking the required bits to create a new web page. Cheers, James
|
 |
 |
|
|
subject: A couple of init() questions...
|
|
|