servlet 3.0 @WebServlet use..what will be in web.xml?

user460920 picture user460920 · Apr 1, 2012 · Viewed 17.7k times · Source

I want to know the directory structure for using servlet 3.0 with Tomcat 7. I have used annotation @WebServlet without initialization parameters.

I want to know what is to be written in web.xml file then?? Is and is still to be written...??

The file is stored in the classes folder of the tomcat.

Answer

Tomasz Nurkiewicz picture Tomasz Nurkiewicz · Apr 1, 2012

This is all you need in web.xml:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  version="3.0">

3.0-compatible servlet container (like Tomcat 7) will find @WebServlet automatically.