Solved

Nesting mixed Scriptlets and HTML

Posted on 2006-11-12
7
1,501 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
json example 39 179
wordcount challenge 11 163
micro services vs rest web services 16 217
batch vs regular insert in spring DAO 2 51
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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.

738 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