Get all updates of Java4s
Follow Us: Email Newsletter

How to Write Deployment Descriptor,web.xml In Servlet

Servlets » On Jan 5, 2013 { 18 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

  • 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 Author ♦

Java4s_Author
sivateja@java4s.com
Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. Sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

18 Responses to “How to Write Deployment Descriptor,web.xml In Servlet”
  1. N kiran says:

    Hi Java4s Team,
    Really superb explanation … i really thank so much…

  2. Wesley says:

    great explanation men.. will help the newbies even more compared to other tutorials !!

  3. Shrika says:

    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.

  4. Kiran says:

    Super Duper Well Nice…

  5. This is really wonderful explanation thank you very much to giving us a great tutorial and guide us

  6. Kalaichelvi says:

    Hi,
    awesome explanation… Its very helpful.. Thank yu so much:-)

  7. Pankaj Kumar says:

    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.

  8. amar kumar says:

    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.

  9. Nandha says:

    Your Explanation is really Good .Till now I don’t know about the servlet how it runs, now its cleared

  10. prashanthi says:

    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.

  11. Rohan Sutar says:

    awesome explanation…thanks

  12. sindhuja says:

    super’b explaination. every one can easily understand

  13. vadgama kapur says:

    Hi sir i really like your website thanks

  14. krishna says:

    Is it possible to write multiple web.xml files in single web application in servlet,if we can please elaborate it. Thanks

  15. sai chandra reddy says:

    really a great explanation.thank you javas4s

  16. pavanireddy says:

    Hi,
    This is awesome explanation,also "JAVA4S" is very useful for us for clarifying the doudt easily …….
    GREAT JOB….>thank you so much..

  17. anveshreddy says:

    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.?

  18. Moula Ali shaik says:

    Damn effective explanation and we are expecting more articles please.

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
Upcoming
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2016 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.