• 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

How can I invoke a servlet through a simple java class

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In my application I need to run a servlet after fixed time interval. Now I've a thread running as a daemon process, which I plan to use to call this servlet.
The problem is how to invoke the servlet through that thread, a simple java class?

Ajay
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ajay,
Although quite old now, this article may help you (assuming you haven't already read it)

http://www.javaworld.com/javaworld/jw-03-2001/jw-0323-traps.html

Good Luck,
Avi.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does the Servlet do? If you are calling a servlet from a process than I assume any GUI output is not relevant (unless your process is parsing any generated HTML). You might consider, if its possible, to move the common functionality needed in the servlet and by your process to a plain old java object so both can use it regardless how its invoked.

Otherwise to get your servlet to do whatever it does you need to send it an HTTP request. You could use a Timer object to do this via the classes in the java.net package.
 
ajch Chawla
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Avi and Paul,

I used java.net and was able to send the request.

Thanks
Ajay
 
reply
    Bookmark Topic Watch Topic
  • New Topic