| Author |
getting error in switch statement
|
gino jersey
Greenhorn
Joined: May 24, 2005
Posts: 21
|
|
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
Joined: Dec 11, 2004
Posts: 13410
|
|
Why are you prepending ints with zeros? 08 09
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56190
|
|
Moved to Java in General (beginner). By prepending a 0, you are creating octal constants. And since octal only contains digits 0 through 7...
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: getting error in switch statement
|
|
|