• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting error in switch statement

 
gino jersey
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone.

In a JSP page I'm updating there is a switch/case statemnt. The code is as follows:

String strMonth= request.getParameter("month");
String getmnth = strMonth.substring(0,2);
String m="";
int mn = (new Integer(getmnth)).intValue();
switch(mn) {
case 01:
m="January";
break;

case 02:
m="February";
break;

case 03:
m="March";
break;

case 04:
m="April";
break;

case 05:
m="May";
break;

case 06:
m="June";
break;

case 07:
m="July";
break;

case 08:
m="August";
break;

case 09:
m="September";
break;

case 10:
m="October";
break;

case 11:
m="November";
break;

case 12:
m="December";
break;

default:
m = "Unknown";


}


I'm getting an error that states:
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.


An error occurred between lines: 5 and 82 in the jsp file: /Data/Primary/entity2.jsp

Generated servlet error:
d:\WebApps\FinEssbase\work\Data\Primary\entity2$jsp.java:115: Invalid character in octal number.
case 08:
^


An error occurred between lines: 5 and 82 in the jsp file: /Data/Primary/entity2.jsp

Generated servlet error:
d:\WebApps\FinEssbase\work\Data\Primary\entity2$jsp.java:119: Invalid character in octal number.
case 09:
^

Seems to be a pretty straightforward switch statement.

Any ideas?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you prepending ints with zeros?
08
09
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Java in General (beginner).

By prepending a 0, you are creating octal constants. And since octal only contains digits 0 through 7...
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic