Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I invoke a servlet through a simple java class

 
ajch Chawla
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi Avi and Paul,

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

Thanks
Ajay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic