Solved

Nesting mixed Scriptlets and HTML

Posted on 2006-11-12
7
1,496 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
starter POM and spring-boot-starter,  spring-boot-web 2 74
servlet example issue 6 56
hibernate example issues from command prompt 10 63
Java: The Public Class Main 4 45
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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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.

713 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