Nesting mixed Scriptlets and HTML

Hi!

This is a basic question concerning nesting mixed Scriptlets and HTML.

Say that you have some JSP-code like this:
<TABLE BORDER=2>
<%
    for ( int i = 0; i < n; i++ ) {
        %>
        <TR>
        <TD>Number</TD>
        <TD><%= i+1 %></TD>
        </TR>
        <%
    }
%>
</TABLE>

- i.e. mixed Scriptlets and HTML.

My question now is: Can mixed Scriptlets and HTML be nested?

Say that the code above should only be carried out if some condition is meet, i.e.:

<%if (some condition) { %>
  ..some mix of Scriptlet and HTML..
<% } %>

Will this work?

Regards,
Jesper
jespersahnerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
VenabiliConnect With a Mentor Commented:
Yes - no problems at all :)
0
 
rrzConnect With a Mentor Commented:
But much easier with JSTL.
0
 
jaggernatConnect With a Mentor Commented:
scriplets are outdated. As rrz said, use jstl.
take a look
http://www.informit.com/articles/article.asp?p=30334&rl=1
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
rrzCommented:
>scriplets are outdated  
Not really, Sometimes I like to use print method.
<TABLE BORDER=2>
<%
    for ( int i = 0; i < 6; i++ ) {
        out.print("<TR><TD>Number</TD><TD>" + i + "</TD></TR>");
    }
%>
</TABLE>
0
 
jaggernatCommented:
>>Not really

I know LOL :-).  Dint mean it literally.
0
 
VenabiliCommented:
>scriplets are outdated  

Maybe :) But are working.
Besides sometime I love writing them... simply to remember the old days :)
0
All Courses

From novice to tech pro — start learning today.