Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling jsp from another jsp or print messege depending on conditions

 
somu sharma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,

I want to print messeges or call jsp from another jsp depending on conditions. Like ..

while(condition){
//Here my thread waits for some time......
out.println("first messege.......................")
}
condition complted
out.println("second messege")

But what happening is it displaying both messeges same time like "first messege second messege."

How can I handle this scenario ?

 
Manjunath Gajula
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your case, First one would get printed when Condition satisfies where in second one would get printed every time irrespective of first one is printed or not.
So,
Define a variable outside first.
<bean:define id="print" value = "true"/>
While(condition){
//Here my thread waits for some time......
out.println("first messege.......................")
<bean:define id="print" value = "false"/>
}
<logic:equal name="print" value="true">
out.println("second messege")
</logic:equal>
So, When First one get printed, second one wont. Vice versa..
 
somu sharma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Manjunath.

I tried this but not worked.

boolean myvar=true;
While(condition){
//Here my thread waits for some time......
out.println("first messege.......................")
myvar=false;
}
if(myVar=true)
out.println("second messege")


But same thing is happening printing together messege after all finishes "first messege.......................second messege"

I have index.jsp on which I am hitting submit button then I am calling home.jsp where I have written above code.
 
Manjunath Gajula
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
boolean myvar=true;
While(condition){
//Here my thread waits for some time......
out.println("first messege.......................")
myvar=false;
}
out.println("Value of myVar :: "+myVar);
if(myVar==true)
out.println("second messege")
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Causing the thread to wait is never going to work. Please read this article to understand how JSP works. All you are doing is causing needless delays in generating the response.

What you require needs client-side interaction using JavaScript on the page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic