Wednesday, 15 May 2013

java - How to override @WebInitParam of servlet without recompilation? -



java - How to override @WebInitParam of servlet without recompilation? -

i have java servlet next @webservlet annotation:

@webservlet(urlpatterns={"/getinfo"}, initparams={ @webinitparam(name="directory.path", value="/appli/pdlinfo")})

how can alter value of @webinitparam without recompiling servlet?

in servlet 3.0 annotations provide default value. using web.xml file (or tools available on container @ deployment time) alter it. either case need give servlet meaningful name:

@webservlet( name="getinfo" urlpatterns={"/getinfo"}, initparams={@webinitparam(name="directory.path",value="/appli/pdlinfo")} )

for web.xml here snippet:

<servlet> <servlet-name>getinfo</servlet-name> <init-param> <param-name>directory.path</param-name> <param-value>/other/path</param-value> </init-param> </servlet>

java java-ee servlets servlet-3.0

No comments:

Post a Comment