Eclipse eliminates the need to create a web.xml file when creating a dynamic web project for Java EE 6, because the Java EE 6 specification (in general) and the Servlet 3.0 specification (in particular) try to cancel the underline of deployment descriptors.
You can use the annotation to provide all the data that was included in the web.xml file. Javadoc for Servlet 3.0 annotations is pretty dumb. You should read the Servlet 3.0 description from jcp.org to get a more explanatory text.
To change the url-mapping for the Servlet 3.0 servlet, the first thing to look at is in the servlet source code. Find (and change) the value of the urlPatterns element.
If you are trying to create a web application based on Servlet 3.0, try to avoid creating a web.xml file.
The sun-web.xml / glassfish-web.xml file is used to "complete" the description of the military file for deployment in the GlassFish container.
One more note about annotations like WebServlet ... they do not integrate your annotated class into the class hierarchy, so using @WebServlet correctly will look like
@WebServlet( name = "MyServlet", urlPatterns = {"/path_to_servlet"} ) public class MyServlet extends HttpServlet {}
vkraemer
source share