Reputation: 23352
I was reading about Initialization Parameters for Servlets on this blog post by Jenkov.
It made me wonder though, when would I ever need to initialize variables this way? If I wanted to predefine certain values, why not just do it with fields in the Java code?
Upvotes: 0
Views: 104
Reputation: 868
It could be useful if your servlet was packaged in a jar for use by another user, who could then set the input parameters to their own specification in their own servlet definition. If you hard coded it, they could not otherwise 'configure' your servlet.
Upvotes: 3
Reputation: 73568
Because if you need to change those variables, one requires the editing of web.xml and restarting of the servlet, and the other (your suggestion) requires the recompilation of the application.
Upvotes: 1