aspose file tools*
The moose likes Servlets and the fly likes How can I invoke a servlet through a simple java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How can I invoke a servlet through a simple java class" Watch "How can I invoke a servlet through a simple java class" New topic
Author

How can I invoke a servlet through a simple java class

ajch Chawla
Greenhorn

Joined: Jan 10, 2005
Posts: 7
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

Joined: Oct 11, 2000
Posts: 1135

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

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
ajch Chawla
Greenhorn

Joined: Jan 10, 2005
Posts: 7
Hi Avi and Paul,

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

Thanks
Ajay
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I invoke a servlet through a simple java class