Invocation of a Servlet requires to have a request object and a response object. Since the event of starting the application has nothing to do with a request or response, there isn't a proper way to call a Servlet. If you need some code to be executed at the application startup, you can setup a context listener.
Abhay Agarwal wrote:If you want Container to run your servlet at start up of application, try exploring <load-on-startup> element of web.xml. With this, you can load servlet at the start of application.
Just for not to make the OP confused: <load-on-startup> does nothing other than instantiating the servlet and calling the init() method. In other words, neither doGet or doPost is called by that.
Note that an Applet is an application that runs at the client end. If you need to send something from your Applet to a web server, you can do that by sending a typical HTTP request. If you have a problem in doing so, please start a new topic in our Applets forum.
The applet has to call a server to get the data for the Swing model. If the server is a web server using servlets, the servlet will be automatically started when the first request comes in.
You can specify load-on-startup in the web.xml file to cause the servlet to be loaded when the webapp first starts up, and that will save a little time when the first servlet request is made, but other than that, the results will be the same as the default on-demand servlet startup. Once the servlet has started, it remains available until the webapp is shut down.
Note that I said "available", not "running". That's because servlets are not programs, and they don't "run". They don't have their own private execution threads. A servlet is more like a DLL than an executable in that respect, if you prefer to think of it in Microsoft Windows terms.
An IDE is no substitute for an Intelligent Developer.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com