File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes How to exit from the for loop in jsp scriptlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to exit from the for loop in jsp scriptlet" Watch "How to exit from the for loop in jsp scriptlet" New topic

How to exit from the for loop in jsp scriptlet

RameshKumar Mathiyazhgan

Joined: Mar 30, 2013
Posts: 1
]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

Joined: Mar 22, 2005
Posts: 42956
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

Joined: Jan 10, 2002
Posts: 62799

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]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: How to exit from the for loop in jsp scriptlet