• 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

calling jsp from another jsp or print messege depending on conditions

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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")
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic