0

Hi everyone it has been a long time I was looking for the solution but even if I found some explanation it wasn't that clear.

I want to replace an URL in the web.xml with its key defined in URL.properties here is the URL I want to replace in web.xml

<param-name>chainConfig</param-name>
<param-value>org/apache/struts/tiles/chain-config.xml</param-value>

In my properties file I have :

URL.chainconfig=org/apache/struts/tiles/chain-config.xml

So I want to use in my web.xml something like ${URL.chainconfig} instead of the full URL.

Thanks in advance

AlexB
  • 7,302
  • 12
  • 56
  • 74
ali
  • 1
  • 2

2 Answers2

0

One way is you can set the value to environment variable and read it using ${vaiableName} inside your web.xml

In Linux type sudo vim /etc/profile export URL.chainconfig=org/apache/struts/tiles/chain-config.xml

Save and exit. Now it will get replaced in web.xml during run-time.

Krishna
  • 198
  • 2
  • 2
  • 12
  • thanks for ure quick answer i appreciate a lot,only am workin under windows.i heard about a class which implements ServletContextListener that may help i use it but still cannot recognize my key in the web.xml. – ali May 04 '15 at 09:09
  • Ali In windows also you can set environment variables, you can try that also – Krishna May 04 '15 at 09:19
  • if my way is totally wrong is there any way to configure the environnement variables in windows – ali May 04 '15 at 09:20
  • one last thing krishna.do we need to set a environnement variables for every machine where the programme will run if its so,its not the solution – ali May 04 '15 at 09:23
  • bad news am not allowed to modify the environnement variables. – ali May 04 '15 at 09:26
  • am in internship and wedont have this kind of rights – ali May 04 '15 at 09:27
  • ya you need to set it either manually or you need to write a listener which will read and set it. – Krishna May 04 '15 at 09:27
  • yeah taht what i did is my class listner is correct?if yes what else should i add? – ali May 04 '15 at 09:35
-1

I solved the very same problem without environment variables, creating a new InitListener that reads the desired properties, as described here:

https://stackoverflow.com/a/12099590/3202887

Community
  • 1
  • 1
dipanda
  • 760
  • 1
  • 11
  • 24