File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Invoke servlet from java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Invoke servlet from java class" Watch "Invoke servlet from java class" New topic

Invoke servlet from java class

Sathish Ramadas

Joined: Feb 18, 2004
Posts: 27
How do you invoke a servlet from a simple java class.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Take a look at HttpURLConnection and URL classes. They're what you want (you may also want Runnable and Thread to avoid long waits in your program while the network connection is open).

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
Remember that servlets are intended to run in the servlet container environment such as Tomcat, not as stand-alone programs. It is the servlet container that handles turning your HttpURLConnection into a request.
Sathish Ramadas

Joined: Feb 18, 2004
Posts: 27
Thanks for the information.
I agree. Here's the link:
subject: Invoke servlet from java class
jQuery in Action, 3rd edition