Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace a context-param element with a Servlet 3.0 annotation

Given: a Java EE 5 web app that has a web.xml that has a snippet like

<context-param>
    <description>c</description>
    <param-name>a</param-name>
    <param-value>b</param-value>
</context-param>

What would I need to do to move that context-param specification into an annotation based strategy.

like image 418
vkraemer Avatar asked Nov 01 '11 17:11

vkraemer


1 Answers

If you are using Tomcat, you can use the Parameter tag in context.xml, and it will work identical as a context-param put in web.xml. So you can use @WebInitParam to catch a context variable.

http://tomcat.apache.org/tomcat-5.5-doc/config/context.html#Context_Parameters

like image 117
Miguel Ruiz Velasco Sobrino Avatar answered Oct 01 '22 20:10

Miguel Ruiz Velasco Sobrino