web.xml vs annotation regarding servlet initparameters

web.xml vs annotation regarding servlet initparameters

Postby javalatte » Sun Feb 10, 2013 12:16 am

Servlet init parameters could be done either through the web.xml or through annotations. When you need to make changes to the init parameters for some reason, do the servlets with annotations have to be recompiled, reloaded, etc for the changes to be reflected? Is web.xml better in that aspect or not?
javalatte
 
Posts: 55
Joined: Tue Jan 29, 2013 2:31 pm

Re: web.xml vs annotation regarding servlet initparameters

Postby Kishan » Mon Feb 11, 2013 4:59 am

This is really nice question.

Yes, you can specify init parameters for servlet either through web.xm or servlet annoations in java code itself. When you are specifying in the java code and if you are making any changes you have to recompile the program and redploy with new compiled class. Where as in web.xml change has to restart the server is sufficient.

If you have any configuration changes so often web.xml is good option.

Most of the times In reality, application configuration seperated through database/service/properties file etc... This will give more flexibility to update the configuration to immediately effect in all the servers rather than changing directly in the server.
Kishan
 
Posts: 191
Joined: Tue Jan 29, 2013 4:21 am


Return to Servlets

Who is online

Users browsing this forum: No registered users and 2 guests

cron