dcsimg
Trying to run Java Servlet from main function
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Elena_Neumark
Posted On:   Monday, April 9, 2001 04:59 AM

Hello,
I wrote Servlet I can launch it from WebBrouser (IE) but I have no idea how to run it from another class .
Thanks

Re: Trying to run Java Servlet from main function

Posted By:   Michael_Wax  
Posted On:   Monday, April 9, 2001 08:45 AM

A servlet is not intended to run on its own. Instead, it is designed to be run by a servlet container (e.g., servletrunner, Tomcat), which will invoke its init, service, doGet, and doPost methods as needed. The servlet container (not the servlet) has a "main" method which is invoked at start-up.


If you wanted, you could write a class which calls the servlet, but then you would need to follow the servlet API. Your class would thus need to create ServletRequest and ServletResponse objects to pass to the servlet on a call to its service method. Typically, however, you would want to either use one of the commercially available servlet containers, or to write something other than a servlet.

About | Sitemap | Contact