Sep 9, 2015

Servlet - Part 02

Servlet using XML In servlet - part 01 we use anotation for servlet to mapping servlet. In here we use xml for those purpose. This xml file we call as deployment descriptor of the web application (web.xml). That file responsible for mapping the servlet for the requests. This xml contain the description abouth the application's servlets. keep it remember like that.

Ok lest get understanding about web.xml by an example. Open the netbeans IDE and create a java web application project like i said before in the part 01. Then create a servlet. Befor you create a servlet you should do this as following.

After you did this got to webpages » WEB-INF » web.xml
this is my web.xml for the newly created "NewServlet"


in the "servlet"  tag you define a servlet  class and defind a name for that. Then Servlet container knows where the our NewServlet is located. in "servlet-mapping"  tag define the mapping part for the servlet definded in the "servlet"  tag. Using the definded servlet name set a url pattern for it.

can u remember that how u did this with anotation  in servlet-part-01 ? i feel it is easy than this. :) .


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.