Dusk
Dusk

Reputation: 2201

JSP syntactical error in scripting

I don't understand why the first program in JSP is working, but the second program is giving an error:

<% for(int i=0;i<10;i++){

out.print("hello");
}
%>


<% for(int i=0;i<10;i++){

<%= "hello" %>
}
%>

Upvotes: 1

Views: 94

Answers (2)

Asaph
Asaph

Reputation: 162801

Try it like this:

<% for(int i=0;i<10;i++){
out.print("hello");
}
%>

<% for(int i=0;i<10;i++){ %>
<%= "hello" %>
<%
}
%>

Upvotes: 1

Jonathan Leffler
Jonathan Leffler

Reputation: 753765

At a guess, it is because you can't nest '%<' tags.

Upvotes: 2

Related Questions