File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets 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
Bartender

Joined: Jul 19, 2004
Posts: 5126
    
  12

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/
 
 
subject: Why is this expression wrong?
 
Similar Threads
protected access
please verify this code
Array question - enthuware
GZIPing JSP
is it a valid JSP expression