aspose file tools*
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
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
Bartender

Joined: Jul 19, 2004
Posts: 4919
    
  10

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
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is this expression wrong?
 
Similar Threads
is it a valid JSP expression
Array question - enthuware
please verify this code
protected access
GZIPing JSP