0

Servlet with load on startup

asked 2011-04-14 09:48:49 +0800

sastepankaj gravatar image sastepankaj
21 1

Hi there,
I want to do some initialization stuff on the server startup and not actually when request for application, right now i'm trying to create a servlet with load on startup. But it is not called on startup. When i'm entering the url for that servlet it is called. So is there any way to do this or m i committing some mistake......

Plz reply on this as soon as possible

Thanks.

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2011-04-14 23:42:33 +0800

sastepankaj gravatar image sastepankaj
21 1

I think WebAppInit can do it but i want to start a thread for routine DB scan at specific time. So when i created a listener for WebAppInit a started a thread application's execution is suspended till the time the thread finished its work. I want both to run parallely

import org.zkoss.zk.ui.WebApp;
import org.zkoss.zk.ui.util.WebAppInit;

public class ThreadDemo implements WebAppInit
{
         public void init(WebApp wapp) throws Exception
	{
		try
		{
			MyThread t = new MyThread();
			t.join();
			t.start();
			while(true)
			{
				t.run();
				t.sleep(20000);
			}
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
	}
}

link publish delete flag offensive edit

answered 2011-04-15 05:02:08 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

If you work with spring ?

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-04-14 09:48:49 +0800

Seen: 1,033 times

Last updated: Apr 15 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More