aspose file tools*
The moose likes JSP and the fly likes How to stop the execuation of jsp flow Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to stop the execuation of jsp flow" Watch "How to stop the execuation of jsp flow" New topic
Author

How to stop the execuation of jsp flow

Parshuram Walunjkar
Ranch Hand

Joined: Jan 02, 2002
Posts: 31
<%
boolean flag ;
// Some java execution and set the value of boolean variable
flag = true;
if(flag)
{
%>
<script>
alert(" Here I want to stop");
history.back()
</script>
<%
}
// Some java code to be execrated
//
//
//////

System.out.println(" some printing statement ");


%>
This is my sample jsp code.
If the variable flag is true then I want the alert message and execution to be stopped.
But actually this is not occurred. First the SOP will print and then at lastly the alert will occur.
Why this happens.?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Looks to me like the entire JSP executes and sends a page, no matter what the flag is. Why not finish off the page and execute return if the flag is true.
Bill
Nicolas Brasseur
Ranch Hand

Joined: Nov 09, 2001
Posts: 45
You should first consider how JSP pages are treated by the web container (parsed, translated into a java servlet source file, compiled, instanciated, ...).
you should also consider that you are mixing JSP tags (that will become java code executed on the server) with Javascript code (that will be executed on the client-side) ...
Whatever ... looking at your code I think adding a return should solve your problem ...


Nicolas


<a href="http://www.javablackbelt.com/?utm_source=javaranch&utm_medium=signature&utm_campaign=Forum%2BBuzz" target="_blank" rel="nofollow">BlackBeltFactory Communtiy</a> founder - Building better developers<br /><b>Free</b> courses and mock exams
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to stop the execuation of jsp flow