# Hardcoding policies

As of version 2143 configuration values can be hardcoded/overloaded.

The server policies can be hardcoded into the deployment file for various reasons

1. Ensure system values are not subject to change in the designer
2. Ease environment replication: Just copy the whole database, and define environmental differences in a file.

Typical fixed parameters include

- Application name
- Server daemon autostart
- SMTP server testmode
- Base schema name

### <span class="mw-headline" id="bkmrk-adding-an-overloaded-1">Adding an overloaded policy</span>

Policy overloads are placed inside the Context element in the deployment file, where the connection strings are placed too.

- Tomcat: &lt;tomcat root&gt;/conf/Catalina/localhost/&lt;application&gt;.xml
- JBoss: &lt;jboss root&gt;/standalone/configuration/&lt;application&gt;.xml

The policy in question should use the following syntax:

```xml
<Parameter name="Policy.XXXXX" value="YYYYY"/>
```

X = Name of the policy as per [Policy reference](https://docs.tsnocode.com/books/policy-reference)

Y = Value of the policy in String, Integer or Boolean format

### <span class="mw-headline" id="bkmrk-usage-notes-1">Usage notes</span>

- Place in the context file of the application 
    - Tomcat: &lt;server root&gt;/conf/Catalina/localhost/&lt;application&gt;.xml
- The syntax for naming is: "Policy." + configuration name 
    - Boolean values use: \[true|false\]
- The Context parameters can optionally be set inside the servlet container manager
- Changing overloaded policies inside the designer will have NO EFFECT at all
- Please ensure the datatype fits Policy type, or the overloaded value will default to the installation value. 
    - For boolean values use "true" or "false"
    - String value " should be escaped normally
- Policy overloads are loaded ONCE when the application is loaded by the servlet container. 
    - If you change the values, you will need to restart the application or the container
    - All parameters are written to the server / application logfile upon startup

### <span class="mw-headline" id="bkmrk-example-1">Example</span>

```xml
 <?xml version="1.0" encoding="UTF-8"?>
 <Context path="/TempusServa" >
     <Parameter name="Policy.applicationName" value="Test server"/>
     <Parameter name="Policy.smtpTestMode" value="true"/>
     <Parameter name="Policy.dbNameBase" value="sandboxtest"/>
     /* More configuration values  */
     /* Connection strings etc.  */
 </Context>
```

### <span class="mw-headline" id="bkmrk-protecting-the-varia-1">Protecting the variables</span>

By setting the special policy **policyHideValues**, overloaded are no longer visible from backend system.

```xml
<Parameter name="Policy.policyHideValues" value="true"/>
```