Newsletter |
How to Write Deployment Descriptor,web.xml In Servlet
Servlets » on Jan 5, 2013 { 22 Comments } By Sivateja
This web.xml is like index of book, web.xml is containing details of static web resource programs and dynamic web resource programs. The purpose of web.xml is to hide [or] to achieve the security for the web application by not showing [ in the URL ] the type of technology used for development of web application.
Deployment Descriptor [ web.xml ] in Servlets
Syntax
<web-app> <servlet> <servlet-name> Give Some Dummy Name </servlet-name> <servlet-class>/Flly qualified name of our servlet</servlet-class> </servlet> <servlet-mapping> <servlet-name> Give Some Dummy Name </servlet-name> <url-pattern>/UserFriendlyName</url-pattern> </servlet-mapping> </web-app>
- We must call our servlet by typing its <url-pattern> only
- For example http://localhost:8080/OurServletApplicationFolderName/UserFriendlyName
- Once we call our servlet just like above, then the server will first loads web.xml and verifies whether the url pattern we are calling is same as what in <url-pattern> tag in web.xml [Line number 8] or not
- If matched, it will checks the <servlet-name> [Line number 7] and will jump to <servlet-name> [Line number 3] in <servlet> tag and, will check whether the value of <servlet-name> in line number 3 & line number 7 are same or not if same it will load our class in <servlet-class> [line number 4]
- Finally our .class file will be executed, so we can check the output
You Might Also Like
::. About the Author .:: | ||
Comments
22 Responses to “How to Write Deployment Descriptor,web.xml In Servlet”
Hi Java4s Team,
Really superb explanation … i really thank so much…
great explanation men.. will help the newbies even more compared to other tutorials !!
http://localhost:8080/OurServletApplicationFolderName/UserFriendlyName
In the above URL, OurServletApplicationFolderName is the root folder name right?
Can we make it case sensitive?
I mean
http://localhost:8080/OURSERVLETAPPLICATIONFOLDERNAME also should work.
Super Duper Well Nice…
This is really wonderful explanation thank you very much to giving us a great tutorial and guide us
Hi,
awesome explanation… Its very helpful.. Thank yu so much:-)
That is a very wonderful explanation. Before this, I searched hundreds of pages for web.xml. But they didn’t satisfy my doubt. But your this article helped me a lot.
Sir,really your description is one of the best but one doubt in my mind .Sir is it possible to check the flow of execution of web.xml file.
Your Explanation is really Good .Till now I don’t know about the servlet how it runs, now its cleared
Hi sir i really like your website very much.you explained all topics step by step superb.examples and explanaton is very nice.but not yet explained about SPRING SECURITY.we are waiting for explaination about SPRING SECURITY soon.
awesome explanation…thanks
super’b explaination. every one can easily understand
Hi sir i really like your website thanks
Is it possible to write multiple web.xml files in single web application in servlet,if we can please elaborate it. Thanks
really a great explanation.thank you javas4s
Hi,
This is awesome explanation,also "JAVA4S" is very useful for us for clarifying the doudt easily …….
GREAT JOB….>thank you so much..
Hi,
I have an doubt in web.xml, what is the use of dummy name.why can't we write directly with servlet name and url pattern.?
Damn effective explanation and we are expecting more articles please.
nice explanation….
How to add a validation filter to this
Hi Java4s Team,
Really superb explanation …
great explanation.
keep it up.. I Follow Only java4s.com.
Superb explanation.