• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

JSP/Java: Why doesn't this switch() work?

apinomus

Senior member
So I'm trying to do some work on another site that uses JSP... and while I could do all of this 100x faster in PHP, they insist it stays JSP because "that's what our guys know" so whatever. Could somebody tell me why this causes my script to error?

It's supposed to bring in the GET variable t= from the URL, compare it to all cases in the switch to make sure its a valid type, then pass it into the hidden form field to be POST'd to the next page of the form. If it's not valid, then show the drop-down menu so they can select what they want.

Thanks for any help you guys can give me.

http://localhost/myform.jsp?t=voice_new
 
Yeah, kind of stupid. I've always hated doing a bunch of else ifs instead of switches with strings in java.
 
Originally posted by: JasonE4
Yeah, kind of stupid. I've always hated doing a bunch of else ifs instead of switches with strings in java.

Not even that. Hell, if this were PHP I'd be doing if(in_array($testval, $safevals)), or a foreach() or something of the 20 different ways you could do it, but lack of how to do those iin Java results in:
 
Originally posted by: apinomus
Originally posted by: JasonE4
Yeah, kind of stupid. I've always hated doing a bunch of else ifs instead of switches with strings in java.

Not even that. Hell, if this were PHP I'd be doing if(in_array($testval, $safevals)), or a foreach() or something of the 20 different ways you could do it, but lack of how to do those iin Java results in:

java has very rich collections, there's no need to write code like that
 
Back
Top