How do I execute a servlet from the command line, or from Unix shell program or Windows BAT file?
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).
Or are you saying that you have some utility classes & methods that might be useful to run, standalone in a command line situation (e.g. calling them from main()), as well as from inside a servlet (e.g. calling them from doGet/doPut/service)?
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).