Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 4th, 2001, 04:52 AM
JohnnyJazz JohnnyJazz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Liverpool, UK
Posts: 0 JohnnyJazz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

I'm investigating JSP and servlets for a large project, and would like to know whether servlets can be scheduled to run automatically on the server?

I would like to achieve similar fuctionality to Lotus Domino agents which can be scheduled to run at for example midnight, or every hour etc.

Also can JSP fetch an external URLs raw HTML and assign it to a variable?

Many thanks
JohnnyJazz

Reply With Quote
  #2  
Old May 7th, 2001, 01:03 PM
NJ88025 NJ88025 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Jersey City, NJ
Posts: 0 NJ88025 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool

You could turn your servlet into a thread:-

public class TimerServlet extends HttpServlet implements Runnable

Then in the init you can set up your variables:-

public void init(ServletConfig config) throws ServletException

Then in the run method:-
while( true ) { // run forever....
try {
theDate = new Date();
// --------
Calendar rightNow = Calendar.getInstance();
int currentHour = rightNow.get(Calendar.HOUR_OF_DAY);
int currentMinute = rightNow.get(Calendar.MINUTE);
int currentDayOfWeek = rightNow.get(Calendar.DAY_OF_WEEK);
if ((currentHour == previousRunHH) &&
(currentMinute == previousRunMM)) {
//
Thread.sleep(2000); // try again in 2 seconds
} else {
code to do something
}
} catch (Exception e) {
println(logPrefix() + ":run() Exception [" + e + "]");
} // try()
} // end while
}

// now you could just sleep fo an hour after adjusting to get to the first round hour...

Reply With Quote
  #3  
Old May 7th, 2001, 01:06 PM
NJ88025 NJ88025 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Jersey City, NJ
Posts: 0 NJ88025 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool

Also forgot to mention you can specify Autoload in your application server, I use IBM WAS/VAJ and this loads your server which because it's now a thread will be initialized and you will now run....

Not to sure about the URL though...

Reply With Quote
  #4  
Old May 7th, 2001, 01:08 PM
NJ88025 NJ88025 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Jersey City, NJ
Posts: 0 NJ88025 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

I just noticed you are from Liverpool, Say hi to my mum, she lives in Stoneycroft, I left there over twenty years ago and ended up here.

Peter.

Reply With Quote
  #5  
Old May 7th, 2001, 01:45 PM
JohnnyJazz JohnnyJazz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Liverpool, UK
Posts: 0 JohnnyJazz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the reply Peter.

Servlets/JSP is looking a real promising solution as it looks like it can accomodate all our requirements more efficiently.

What would be advantageous is if you knew where i could download a complete programmers guide to using JSP/servlets which lists syntax, classes, code examples, etc, preferably in PDF format.

I'll shout hi to your Mum - i'm in Tuebrook.

Cheers
JohnnyJazz

Reply With Quote
  #6  
Old May 7th, 2001, 02:25 PM
NJ88025 NJ88025 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Jersey City, NJ
Posts: 0 NJ88025 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool

We use servlet/Jsp's a lot, and I mean a lot, I have yet to come across anything we can not do (Internet wise) with this env. I like to think of a servlet as the TSR of java programming, as you get an enormous amount of support from the servlet environment.

If you can spare some money, I know I did'nt have much in TueBrook, the O'Reilly books, and there is a servlet ver 2 book out now, are really good.


URL is a good resource for documentation/samples.

keep the faith...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Can you schedule servlets to run automatically


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT