TransWikia.com

Can you use a variable from context.xml in the web.xml

Stack Overflow Asked on December 16, 2020

I have a defined resource in context.xml with credentials that need to be fed into the web.xml file as the app uses hardcoded credentials within the web.xml to start. What do I use to make the credentials from the context.xml populate the web.xml dynamically?

context.xml resource:

  <Resource name="jdbc/myDataSource" auth="Container" type="javax.sql.DataSource"
  driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@1.1.1.1:1521:XE" userName="myUsername"
passWord="myPassword"/>

And this is where I need the username and password to get inserted in the web.xml for JDBCUser and JDBCPassword

<init-param>
         <param-name>JDBCDriverClass</param-name>
         <param-value>oracle.jdbc.driver.OracleDriver</param-value>
      </init-param>
      <init-param>
         <param-name>JDBCUrl</param-name>
         <param-value>dbc:oracle:thin:@1.1.1.1:1521:X</param-value>
      </init-param>
      <init-param>
         <param-name>JDBCUser</param-name>
         <param-value>userName</param-value>
      </init-param>    
      <init-param>
         <param-name>JDBCPassword</param-name>
         <param-value>passWord</param-value>

Would something like this work?

<param-name>JDBCPassword</param-name>
             <param-value>${userName}</param-value>

Not sure how to go about this.

One Answer

No, you can't populate web.xml dynamically

Answered by saonnet on December 16, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP