| Author |
What are the scriplet rules for conditionals without braces?
|
Jay Urbain
Greenhorn
Joined: May 24, 2002
Posts: 4
|
|
Hi, What are the JSP scriplet rules for handling conditionals that are not using { braces } to denote code blocks? I found an example similar to the one I created below in the SCWCD Certification book. As it turns out, the example below generates: "Howdy, Bill: welcome to overpricedstocks.com! Your stocks are down today." With Tomcat, the following servlet code is generated (note the ";") from the example: if( displayName ) out.write("\r\n "); Is this standard behavior for all app servers? Thanks, Jay Example: <html> <head><title>Untitled</title></head> <body> <% String name = "Bill"; boolean displayName = false; if( displayName ) %> <b>Howdy, <%= name %></b>: <i>welcome to overpricedstocks.com!</i> <br> Your stocks are down today. </body> </html>
|
Jay Urbain<br />Upstream Development, LLC
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
What are the JSP scriplet rules for handling conditionals that are not using { braces } to denote code blocks?
Simple: don't! You have no idea how many statements are going to be generated, so leaving off braces is just asking for trouble. What compels you to leave off the braces? hth, bear
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Jay Urbain
Greenhorn
Joined: May 24, 2002
Posts: 4
|
|
Bear, It was discussed in the SCWCD Certification book and I thought I should know it for the test (you probably know how anal those certification exams could be). I would think this behavior would be defined. Tx, Jay
|
 |
 |
|
|
subject: What are the scriplet rules for conditionals without braces?
|
|
|