How do I execute a servlet from the command line, or from Unix shell program or Windows BAT file?
Of course as with any Java class, you could put a "main" method in your class that extends HttpServlet, so you could run it (the main(), not the doGet/doPut/service()) from a command line.
But it wouldn't have the whole server infrastructure set up for it, with the request, session, response, etc. (which is why you couldn't call the doGet/doPut/service, unless you have a good "mock object" test scaffolding set up).
In that case, perhaps you would want to make a Jar file with just the utility classes, and an application with main() that uses the Jar file, and also a web application WAR file that uses the Jar file too (in its WEB-INF/lib).