Avatar of vrmetro
vrmetro
Flag 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

JavaJSP

Avatar of undefined
Last Comment
Jim Cakalic

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
sunithnair

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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
Jim Cakalic

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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

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

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
vrmetro

ASKER
Sorry I missed the rest of his first code example.  Ty
Jim Cakalic

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