Ken Martin wrote:
>
> Can I set a variable using this syntax?
>
> <%= test ? "true" : "false" %>
>
> I'd like:
>
> <%= test ? q = "true" : q = "false" %>
>
> Where can I get simple structure information like this? I finally got "Web
> Development with JSP", but it doesn't seem to spend much time here. I gotta
> say, I've spent hours looking at many web sources, but can't find a nice
> "this does this... use it this way (some examples)..." information source.
This is a Java language question, so you would have a better chance finding
info about it in a Java programming book, or online tutorial, than in books
and documents about JSP. Anyway, if you like to assign a String variable q the
value "true" or "false" depending on a condition, you can do it this way in
a JSP scriptlet:
<% String q = (a > b ? "true" : "false"); %>
The values after the question mark represent the result of the expression
when the boolean expression before the question mark evaluates to true and
false respectively. You can not do assignments or anything like that after
the question mark, only specify the result values.
If you want to add the text "true" or "false" to the response depending
on a condition, you can use the construct in a JSP expression:
<%= (a > b ? "true" : "false") %>
The result of the JSP expression is sent to the browser.
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets