Q:

Compare variable values in scriplet and javascript

I have a jsp file with a scriptlet tag, I am getting the values of .properties file in it .I have a java script tag in which I am storing the value from the dropdown in a variable. On selecting some value in the dropdown I want to compare it with the property in the scriptlet and if it is equal a value from properties file must populate in my textbox. I have tried the following code but it is not working
My scriplet tag
     <%
 Properties prop = new Properties();
 String propFileName = "server. properties";

       InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);

        if (inputStream != null) {
        prop.load(inputStream);
        } else {
      throw new FileNotFoundException("property file '" + propFileName + "'not found in the classpath");
     }
    String appName = prop.getProperty("Demo_name");
  String link = prop.getProperty("Demo_Links");
 String database = prop.getProperty("DemoApps_DataBase");
  %>

JavaScript
     <script type="text/javascript">
        function OnSelectionChange(serverName) {
            var selectedOption = serverName.options[serverName.selectedIndex];
            var txtbox=document.getElementById('serverLink');
            var appName=<%=appName%>;
           var links=<%=link%>
           alert(appName.value);
           if(selectedOption.value==appName.value){
                  txtbox.value=links.value;

               }
        }
  </script>

A:

Try this code. Is Your selected value is case sensitive?
 <script type="text/javascript">
            function OnSelectionChange(serverName) {
                var selectedOption = serverName.options[serverName.selectedIndex].value;

                var txtbox=document.getElementById('serverLink');
                var demoName='<%=demoServer%>';
                var testName='<%=testingServer%>';
                var PNGName='<%=pngServer%>';
                var DCPName='<%=dcpServer%>';
                var demoLink='<%=demoLink%>';
                var testLink='<%=testingLink%>';
               var pngLink='<%=pngLink%>';
               var dcpLink='<%=dcpLink%>';                                   

                if(selectedOption==appName){
                      txtbox.value=links;
                  }
               if(selectedOption==PNGName){
                 txtbox.value=pngLink;
                }
               if(selectedOption==DCPName){
                  txtbox.value=dcpLink;
               }
               if(selectedOption==demoName){
               txtbox.value=demoLink;
              }
            }
      </script>

