Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

uestion ID :997027961920

 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
uestion ID :997027961920
Which of the following is/are correct JSP scriptlet(s)?
1.
<% int i = 10; %>
System.out.println("starting loop");
<%for(i=0; i< 10; i++) { out.println(i); } %>
2.
<% int i = 0; %>
<% System.out.println("starting loop");%>
<% for(int i=0; i< 10; i++) { out.println(i); } %>
3.
<% int i = 0, s = 0;
System.out.println("starting loop");
for(; i< 10; i++) { s+=i; } %>
4.
<%
System.out.println("starting loop");
for(int i=0; i< 10; i++) {%> looping <%} %>
I think 2 is correct too.Any comment?
 
Win Yu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got "Variable 'i' is already defined in this method.
for(int i=0; i< 10; i++) { out.println(i); }" error. so 2 is not correct.
^
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope 2 is wrong as it is declaring i two times
All the others are correct, any comments
Sridhar

Originally posted by Win Yu:
I got "Variable 'i' is already defined in this method.
for(int i=0; i< 10; i++) { out.println(i); }" error. so 2 is not correct.
^


 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
1,3,4 r prefect from syntax point of view.No error ,but on 3 option,a blank page will come.that's it.
Regards
Zoe
[This message has been edited by zoe dude (edited November 21, 2001).]
 
Be reasonable. You can't destroy everything. Where would you sit? How would you read a tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic