• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP - Java and Javascript 'for' loop problem

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JSP file with inlaid java 'for' loop. I am now writing a javascript function with a 'for' loop. The javascript function is supposed to be executed when a button is clicked in the jsp page.

The problem is after I wrote the 'for' loop for the javascript function, eventhough I haven't clicked the button to execute the javascript, the java 'for' loop gets executed ...

Any help is really appreciated. Thanks!
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kathy,

You may want to read the following article (written by our esteemed moderator, Bear Bibeault):
http://www.javaranch.com/journal/200510/Journal200510.jsp#a1

The thing to remember is that the server side Java/Jsp code and the client side Javascript code run in two different worlds. By the time your Javascript and HTML are rendered in the user's browser, the JSP/Java code is done executing.

If, from your browser, you click on View -> HTML Source, you will see what the JSP/Java code produces. This output gets loaded into the browesr's memory and is then interpreted as HTML and/or Javascript.

The article will do a better job of explaining this than I just did.

-Ben
[ May 19, 2006: Message edited by: Ben Souther ]
 
Message for you sir! I think it is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic