jsp - How to map java servlet with action form by using @WebServlet? -


Since we do not require web.xml in the servlet 3.0, then how can we use @WebServlet correctly ( Suppose i have two servlet classes in separate packages, and two action forms reside in two separate folders)?

The servlet API 3.0 introduces annotation to make deployment easier. In the javax.servlet.annotation package we have @WebServlet : which defines the servlet component.

The web application deployment descriptors are optional in web.xml servlet 3.0. Instead, in the run-time the container will process the comments of classes in web-nfs / classrooms.

Now the question comes in how the container knows which class is the process as you have asked that the two servicelets are src / mypackage1 / ServletOne and src / mypackage2 / ServletTwo and Servlet class definitions are like

  @WebServlet ("/ servletOne") public class ServletOne HttpServlet {......}  
< P> and

  @WebServlet ("/ servletTwo") extends the public class ServletTwo to HttpServlet {. .....}  

When these classes are compiled, it will be stored in the following sequence as .class

When viewing the container above the annotation class definition, it will check the .class files in the specific folder and call it for the required servlet


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -