Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use servlet in timer

 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pls follow this link also for better understanding of query
http://www.coderanch.com/t/375531/java/java/error-while-Timer

=====
i cannot create my servlet object to be passed in
sheduler obj= new sheduler();
// above i created the instance of servlet...in which i have writen
//sendRedirect() function... now how to call the servlet using
// timer.sheduler();
timer.shedule(obj.date.getTime(),1000);

Ok can any body tell me how to call a webpage from a class that is not servlet ...is it possible ?? actually i m developing a servlet which will be invoked at particular time and redirect page to some else page...

so
should i use threads in servlets ? can we use that ? but how..
i mean .... we should pass the object as an argument to Thread class..
can that object be servelt object ???

pls reply

Thanx and Regards,
amit
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My advise is to stay away from managing your own threads in a servlet container unless you really know what you're doing. Using the the Timer object IS creating a thread.

The easiest way to schedule jobs is to use cron and wget or the windows task manager to call a servlet from outside your app. This way, you won't have to keep track of threads, worry about whether they are daemon/non-daemon, deal with reload or Tomcat shutdown issues.
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can servlet be called by windows task sheduler/manager ???

How sir ?

but i am going to deploy the whole application on Linux machine
so what about that ?? sir

pls reply its urgent

thanx and regards,
amit
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir even windows sheduler is not working ...

Are you talking about windows Shedule taks which is in control pannel

any way...... what about linux ?

and is that means that it is not feasible in servlets ???

regards,
amit
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're deploying on a Linux box then it's even easier.

Use cron to schedule a task.
In the task call wget and have it hit your servlet the same way a person with a browser would.

This approach relieves you of all threading concerns.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!