• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Quartz Schedular

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Thanks in advance.
We are using Quartz schedular, Please tell me how to get a ServletContext object from the execute() method of Job. I have tried by
Schedular extends HttpServlet implements Job, but the doGet() method is not calling.

Regards,
Sree
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quartz is independent of the servlet environment. If you want your Job implementation to have access to the servlet context, then you need to make it available to it, e.g. in the constructor, or via a static method in some global object that returns it.
 
sridhar lakka
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your reply.
In my execute method I want to set one value in application scope which means need to set one value in ServletContext.
But, as per you, I should get Servlet Context from some where,Please tell me some what clear.

Regards,
Sree
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My best shot!

I think you are talking about execute method of Job interface.You might want to write a class implementing Job interface and constructor of that taking servlet context as constructor parameter.

class MyJobImpl implements Job {

private ServletContext sc;
MyJobImpl(ServletContext sc){
this.sc = sc;
}
//execute method implementation.
}

During the creation of object you need to pass the reference of servletcontext.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sridhar lakka:
Thanks a lot for your reply.
In my execute method I want to set one value in application scope which means need to set one value in ServletContext.
But, as per you, I should get Servlet Context from some where,Please tell me some what clear.



Passing the ServletContext to the scheduled job doesn't look to be a good approach. What do you want to use from the ServletContext, in the job?
 
reply
    Bookmark Topic Watch Topic
  • New Topic