1.编写servlet类。
这里只是一个简单的servlet,实际的应用过程中可能需要在其中实现复杂的代码。
上面是使用eclipse生成类的简单实现。这个类只是重写了httpservlet的doGet方法。代码如下:
2.修改web.xml文件。
3.测试应用程序。
将整个的web程序部署到tomcat中,启动服务器,然后通过下面的连接访问这个servlet:http://localhost:8080/HelloWorldServlet/HelloWorldServlet,在浏览器中应该显示的就是亲切的hello world。
4.遗留的问题。
在web.xml中url-pattern的规则是怎样的?