aspose file tools*
The moose likes JSP and the fly likes calling jsp from another jsp or print messege depending on conditions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "calling jsp from another jsp or print messege depending on conditions" Watch "calling jsp from another jsp or print messege depending on conditions" New topic
Author

calling jsp from another jsp or print messege depending on conditions

somu sharma
Greenhorn

Joined: Mar 26, 2012
Posts: 6
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

Joined: Dec 21, 2011
Posts: 12
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

Joined: Mar 26, 2012
Posts: 6
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

Joined: Dec 21, 2011
Posts: 12
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

Joined: Jan 10, 2002
Posts: 61652
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling jsp from another jsp or print messege depending on conditions