Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Nested code in If statement

Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this normal that the fragment of code

<% if (true)
text B

is converted in this:

if (true)
out.write("text B\r\n");

is it conform to the spec ?

I think this should not be converted like that but like this:

if (true)
out.write("text B");

in the SCWCD study kit book, they say the following part of code:

<% if(userLoggedIn) %>
Welcome, <%=username%>

is converted to

if (userLoggedIn)
out.write("Welcome, ")

So what should be the conversion ?

Do we have to always use curly braces around the code or not ?

Thanks in advance,
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Your code will not compile
because of a misssing "%>".

Your code is packed into a
Therefore its mutch better to use curly braces always.

Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's recommended to use the curly brackets to cope the snippets... Sometimes, we might accidently forget to code carefully... I always use curly brackets not only in JSP development, but also in simple Java applications...
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic