You need to modify a few files to get your servlet up and running:
Create your servlet source with, at the very least, a doGet()
method:
More importantly put it where your servlet engine is expecting it.
Given a servlet engine context of /my-space
which has a
docBase of /the/path/to/my-space
then you'll want
to put your code in /the/path/to/my-space/WEB-INF/classes
with appropriate modifications for the class' package.
Try javac -d
/the/path/to/my-space/WEB-INF/classes
If you've created your servlet engine context correctly you need to nothing more.
Create /the/path/to/my-space/WEB-INF/web.xml
by
copying the example in the Tomcat distribution! For example, to
access your HelloWorldServlet
as
/my-space/HWS
instead of the more cumbersome
/my-space/com.lunanbay.HellowWorldServlet
you might add
the following:
The format of web.xml
means you have to
put all instances of servlet
before
servlet-mapping
s etc.
Some things to do with servlets.
File Uploading | Raw and Parsed File Uploading |
Two examples of servlets doing file uploads:
Copyright 2002 Lunanbay Limited. All rights reserved.