How do I use switch/case logic using enums in a JSP?

I inherited a JSP that uses switch / case logic based on a single

character that was picked up by a getAttribute method.

String mainInfo = (String)request.getAttribute("MAININFO");

char info = mainInfo.charAt(0);

switch(info){

case'A':

break;

case'B':

break;

...etc...

}

The characters ('A', 'B', etc) in themselves aren't meaningful to the function of the JSP. I'd like to replace the single character with a string

that would be more meaningful.

From what I've been able to read, I could contain all the possible string

values using the enum class, but I've looked at the examples until I'm

cross-eyed, and I can't figure out how I would incorporate it into a JSP.

How & where would I define the enum class so I could essentially do this?:

String mainInfo = (String)request.getAttribute("MAININFO");

switch(mainInfo){

case CASEA:

break;

case CASEB:

break;

...etc...

}

TIA.

[1626 byte] By [ChuckMa] at [2007-10-3 0:46:31]
# 1

There is an example on this page:

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/switch.html

You shouldn't be writing code in JSP's btw. And with this particular example you need to remember that getAttribute will return null if no attribute of the given name ("MAININFO") exists.

YoGeea at 2007-7-14 17:41:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...