Solved

Nesting mixed Scriptlets and HTML

Posted on 2006-11-12
7
1,474 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:jespersahner
  • 3
  • 2
  • 2
7 Comments
 
LVL 20

Accepted Solution

by:
Venabili earned 50 total points
ID: 17926234
Yes - no problems at all :)
0
 
LVL 27

Assisted Solution

by:rrz
rrz earned 50 total points
ID: 17926669
But much easier with JSTL.
0
 
LVL 10

Assisted Solution

by:jaggernat
jaggernat earned 50 total points
ID: 17927460
scriplets are outdated. As rrz said, use jstl.
take a look
http://www.informit.com/articles/article.asp?p=30334&rl=1
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 27

Expert Comment

by:rrz
ID: 17927834
>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
 
LVL 27

Expert Comment

by:rrz
ID: 17927858
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17930010
>>Not really

I know LOL :-).  Dint mean it literally.
0
 
LVL 20

Expert Comment

by:Venabili
ID: 17933325
>scriplets are outdated  

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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
dividesSelf challange 15 82
Understanding websocket example in spring 1 43
mapBully challenge 6 93
wordcount challenge 11 78
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now