• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to exit from the for loop in jsp scriptlet

 
RameshKumar Mathiyazhgan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
]Hi Friends,

I am using JSP scriptlet in javascript and now facing one issue. I am using JSP FOR loop in javascript, but i dont know how to exit from that loop if my javascript condition is true which i have written inside the JSP FOR loop. PFB my code kindly anyone help me in this. Thanks in advance.

 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you misunderstand how JSP works - JSP runs on the server, whereas JavaScript runs on the client (the browser). You can't mix them in the way you're trying to do here.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RameshKumar Mathiyazhgan wrote:I am using JSP FOR loop in javascript

No. You are not. Not at all.

You seem to be under the impression that the JavaScript and the JSP code will execute at the same time. They do not. The JSP executes on the server before the page is sent to the browser. The JavaScript executes on the client after the page has been sent.

You can't just mix them up and expect them to execute together. Please read this article to understand how JSP works.

Also, putting Java code into a JSP is bad practice that has been obsolete for 12 years! 12 years! Do you not think it's time to catch up to 2013?

[Edit: Ulf was quick on the draw and snuck his post in there before me]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic