This week's giveaway is in the Groovy forum.
We're giving away four copies of Groovy Fundamentals video training course and have Ken Kousen on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Why is this expression wrong? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Why is this expression wrong?" Watch "Why is this expression wrong?" New topic
Author

Why is this expression wrong?

Joey Sanchez
Ranch Hand

Joined: Jun 23, 2011
Posts: 86

We know that the scripting variable state is true.

Why is this expression wrong? How would it be the code into _jspService method after translation?


And this is correct


because returns a value and it would appear into _jspService as

Roel De Nijs
Sheriff

Joined: Jul 19, 2004
Posts: 6855
    
  24

The JSP expressions <%= ... %> are placed inside a out.print()

So <%= state ? "yes" : "no" %> is converted into out.println(state ? "yes" : "no");, which compiles without any problem. But with the if-statement the resulting code won't compile. That's also why semicolon in a jsp expression is not allowed.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
OCAJP 7
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is this expression wrong?