Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to refresh JSP page on some event?  RSS feed

 
Rushi Patel
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Respected ALL,

I am making one demo web Application in which i am stuck in between of some logic and implementation. Scenario is as follows:

One page is there for Order(Customer) and another page is for Kitchen(chef).

I want some functionality like whenever Customer Place an Order than and than Kitchen(chef) should refresh the page.
For that I have put all detail of Customer's Order in Context Attribute and Listener for that i have implemented in which i am setting some flag for new Context Attribute Added or Replaced to value 1.

In Kitchen(chef)'s JSP page, I want to check continuously weather the Flag is set or not in infinite loop and also want process the code written in JSP page.
I know this can be achieved by thread and Joining of thread but how to do it ?

Can anyone help for this ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you can't do this with threads.

You'll need to use Ajax on the page to check whether there is new data to update or not.
 
Vicky Vijay
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rushi,


You can use the below code,



by using the above code, the page will be refreshed for every 5 seconds..




"In Kitchen(chef)'s JSP page, I want to check continuously weather the Flag is set or not in infinite loop and also want process the code written in JSP page. "


Place the necessary condition in your JSP, as the page refreshes periodically,

If the condition is satisfied, you can perform your action
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In 1998 that was the only way to do this, now it's not a good way to do that. There's much better control when using a JavaScript timer and Ajax.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!