Link to home
Create AccountLog in
Avatar of vrmetro
vrmetroFlag for United States of America

asked on

Print else if, in an else statement

Hello,

The code below is used to switch between outputs based on environment.  My question is will the internal "else if" print or will that mess up the script?  If so how cna I print the internal else if's?

if ("test.findwhere.com:9021".equals(request.getRemoteHost())) {
// TEST
else if (Country.equals("XS"))db_CONFIGTYPE = "sxlof"; <<--- NEED THIS TO PRINT
}
if ("test.findwhere.com:9021".equals(request.getRemoteHost())) {
				// TEST
				else if (Country.equals("XS"))db_CONFIGTYPE = "sxlof";
			} else if ("staging.findwhere.com".equals(request.getRemoteHost())){
			   	// STAGING
			   	else if (Country.equals("XS"))db_CONFIGTYPE = "sxlof";
			} else {
				// LIVE
				else if (Country.equals("XS"))db_CONFIGTYPE = "sxwf";
			}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sunithnair
sunithnair

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of vrmetro

ASKER

I need to have the conditional statements because it's adding to other elseifs.  is there a way to print the else if statements rather than assigning those values?

SOLUTION
Avatar of Jim Cakalic
Jim Cakalic
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of vrmetro

ASKER

Here's a better glimps
if (Country.equals("US"))db_CONFIGTYPE = "sulof";
	else if (Country.equals("DE"))db_CONFIGTYPE = "edlof";
	else if (Country.equals("CA"))db_CONFIGTYPE = "sulof";
	else if (Country.equals("AU"))db_CONFIGTYPE = "ualof";
 
	/***********************************************
		 And here's the switch!!
	***********************************************/
 
		if ("test.findwhere.com:9021".equals(request.getRemoteHost())) {
			// TEST
			else if (Country.equals("XS"))db_CONFIGTYPE = "sxlof";
		} else if ("staging.findwhere.com".equals(request.getRemoteHost())){
		   	// STAGING
		   	else if (Country.equals("XS"))db_CONFIGTYPE = "sxlof";
		} else {
			// LIVE
			else if (Country.equals("XS"))db_CONFIGTYPE = "sxwf";
		}
	
	/*** Done switching ***/
 
	else if (Country.equals("KZ"))db_CONFIGTYPE = "zklof";
	else if (Country.equals("AC"))db_CONFIGTYPE = "calof";
	DebugLog.write("Country2 = "+Country+FileNwline);

Open in new window

Avatar of vrmetro

ASKER

Would something like this work... sorry cant test myself right now.  :(
if ("test.findwhere.com:9021".equals(request.getRemoteHost())&&(Country.equals("XS"))) {
				// TEST
				db_CONFIGTYPE = "sxlof";

Open in new window

Avatar of vrmetro

ASKER

Sorry I missed the rest of his first code example.  Ty
Ah. I think perhaps this is what you want:

    if (Country.equals("US")) {
        db_CONFIGTYPE = "sulof";
    } else if (Country.equals("DE")) {
        db_CONFIGTYPE = "edlof";
    } else if (Country.equals("CA")) {
        db_CONFIGTYPE = "sulof";
    } else if (Country.equals("AU")) {
        db_CONFIGTYPE = "ualof";
    } else if (Country.equals("XS")) {
 
        /***********************************************
        And here's the switch!!
         ***********************************************/
        if ("test.findwhere.com:9021".equals(request.getRemoteHost())) {
            // TEST
            db_CONFIGTYPE = "sxlof";
        } else if ("staging.findwhere.com".equals(request.getRemoteHost())) {
            // STAGING
            db_CONFIGTYPE = "sxlof";
        } else {
            // LIVE
            db_CONFIGTYPE = "sxwf";
        }
        /*** Done switching ***/
    } 
    else if (Country.equals("KZ")) {
        db_CONFIGTYPE = "zklof";
    } else if (Country.equals("AC")) {
        db_CONFIGTYPE = "calof";
    }
    DebugLog.write("Country2 = " + Country + FileNwline);

Open in new window