Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8127239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:27:19+00:00 2026-06-06T07:27:19+00:00

Adding more and more configurations to my servlet container ( Embedded Jetty in my

  • 0

Adding more and more configurations to my servlet container (Embedded Jetty in my case) I am starting to wonder whether I should put everything into a web.xml or keep the configuration programmatic in the Java code.

Are there reasons to choose web.xml over programmatic approach and vice versa? Are there security reasons or is this only cosmetic?

To me it seems web.xml is better since you dedicate a DSL to do the job instead of pressing everything into the code. On the other side I can look up configuration quickly when I am in the code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:27:21+00:00Added an answer on June 6, 2026 at 7:27 am

    It depends on what you want to configure and your convenience.

    Servlet 3.0 allows you define the metadata in three different ways:

    web.xml, Usually configuration which will change while being deployed on different environments should be configured here. These properties are such as Database properties, properties file, Admin user properties, etc.

    The advantage of defining in web.xml, all the configuration exists at central place and it is easy for documentation etc.Being defined only at one place, it is difficult for maintainence during distributed development. Yes, Again Servlet 3.0 allows web-fragments.xml for which you should be defining library which can again have single descriptor per library.

    Annotations, Anything which can be defined during development but can be also overridden during deployment is defined as annotations.

    The advantage is No need to configure in deployment descriptor unless it has to be overridden. The annotations can give the default values.
    The disadvantage is that the Container has to process all classes for annotations. I don’t see this as big disadvantage.

    Programatically, Anything which you know that is not going to change can be configured programatically The advantage is that the developer is sure that the configuration is not going be altered anytime by anyone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Adding more than one child to a WPF StatusBar results in poor layout with
i am adding more than one link button during runtime but they all have
Is it possible that adding more import statements to your java code could slow
I had asked this question Adding more attributes to LINQ to SQL entity Now,
I've read several XSRF solutions that rely on adding more tokens to the response,
I'm not quite sure what field to use when adding more than 30 days
I have a MyISAM table with more than 10^7 rows. When adding data to
I'm reading these two pages resources Adding more RESTful actions The Rails Guides page
How do I get the ordered numbers bold without adding more tags? Possible in
I'm adding pg_search into a Rails app. I'm not completely understanding the configuration, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.