Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Change init-parameters at Runtime?

Tags:

java

servlets

If I modify the XML to change the value of init parameter I see the changes only when web-app is redeployed.

My question is cant I get around this by setting the values at run time.Is there any API that allow me to change the values dynamically.

like image 462
giri Avatar asked Dec 17 '22 03:12

giri


1 Answers

It's called init-parameter for a reason. So, you can't.

But you can change values at runtime, that's no problem.

  1. After reading the init parameters put them as attributes of the ServletContext (ctx.setAttribute("name", value))
  2. Create a small (password-protected) page that lists all attributes of the ServletContext and gives the ability to change them.
like image 61
Bozho Avatar answered Dec 19 '22 16:12

Bozho