0

Hi there,

I am a complete newbie to JSP so apologies if this is a blindingly obvious question - I have researched on Google, but can't get this working.

I have a simple switch statement as below:

<%
for (int a=0; a<10; a++) {			
  if ( null != countryID[a] ) {
        
  int country = countryID[a];
        
     switch(country) {
  
     case 8:
     out.println("Case 8");
     break;
 
     case 13:
     out.println("Case 13");
     break;

     default:
     out.println("Default case");
     }
   }
}

	%>

If I set the country integer manually (e.g. int country = 18;) the statement works fine, however If I try to grab the integer from countryID[a] (which is necessary to make the switch dynamic) then it doesn't work.

I'd be most grateful for any advice.

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by masijade
0

Hey masijade - sorry for being vague, I just get a blank screen with the above code, there are no error messages.

If I plugin a number manually e.g:

int country = 8;

The page loads and the switch statement works.

Based on your advice not to use scripltets I'm assuming there's a better way to do this however I'm completely new to jsp and our website is due to be replaced in the next few months so I was trying to put together a quick fix in the meantime.

Cheers.

0

Check the logs. There is an error somewhere.

As far as not using scriptlets, all I can say is to read the tutorials (the JEE tutorials, of course).

Edited by masijade: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.