Do I really need to build a complete 'webapp' just to add a simple 'Helloworld' servlet to the server?

Sachin Patil

Not at all. You can put a single servlet anywhere on your hard disk but you will have to configure your path in server.xml and servlet alias in web.xml as usual.

Let me be a bit more descriptive.

If I have my HelloWorld servlet under c:/foo/hello directory, i will set my path in server.xml like

<Context path="/hello" docBase="c:/foo/hello"></context>
And then in web.xml :
that tomcat considers while starting and you can start your servlet.

[However, it's not that big a deal to make a webapp. Just make a directory (say, /home/alex/foo), give it a WEB-INF/web.xml file, and put the servlet classes in /home/alex/foo/WEB-INF/classes, then add the following to server.xml:

<Context path="/foo" docBase="/home/alex/foo" />
Then you can be sure your settings, classpath, etc. are your own, and it'll be portable to other servers (and won't interfere with other contexts).


About | Sitemap | Contact