First off you need to make and compile the Servlet using a package. For example make the Servlet part of package app. Then put the package in the WEB-INF/app/Servlet directory. Below is an example
Example TestServlet:
package app;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class TestServlet extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException
{
//* your code here
}
} // end class (Servlet)
Example deployment web.xml:
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>app.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
This would allow you to access your server from
http://localhost:8080/TestServlet assuming you compiled and everything went okay. You will need to restart tomcat to get the web.xml to reload. Hope this helps.