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 :
<servlet-name>hello</servletname>
<servlet-class>HelloWorld</servlet-class>
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).

-Alex]

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact