Click to See Complete Forum and Search --> : Making a Java Web Application to prompt you to a new page


tony_baez
07-29-2009, 06:01 PM
Hello Everyone! Thanks in advance for reading this.

Here is my situation. I have successfully developed what I called a Cyclic web page that works as follows:

A JSP page that uses java beans to initialize some fields that need to be shown.

When you click the submit button, an associated Servlets its called, does something with the data that was submitted, updates some fields of the beans and then forwards the response of the servlet to that same JSP page.

Nothing too fancy there...

But then I came up with this task. One of the fields that gets updated during the call to the servlet and that afterwards, the same field is called upon by the JSP page basically to show it in the browser, ALSO depends on time calculations by the server side. If a timer fires up in the future (AND HERE IS THE REAL QUESTION) and changes some of the fields of the java classes that I have been implementing as beans, how do I make my web application to instantly show those changes in the JSP page? Some how if the user is simply doing nothing with the JSP page (no request) and then a timer fires up, carrying changes with it, I need that that JSP page show those changes, whether is it by making the page to refresh (at the time the timer says it) and then the new reding on the beans will show those changes or any other way...because, if changes happen and there is no action by the client, the data shown will stay put.

One way to go here is by implementig Applets...applets that communicate directly to the server with no request/response involved by the client (browser)..but before taking that path, I wanted to know if there was a simpler way.

Thank you very much!!
Tony

JavaServlet
07-29-2009, 06:21 PM
Sounds like you need an asynchronous solution using AJAX.

tony_baez
07-29-2009, 08:37 PM
Any suggestions that relates more JSP and servlets? I was thinking that maybe I create another class that runs in a thread, and when that thread becomes ready, I will having him call the doPost() method of the servlet (previously saving the Request and the Response)

But then the IDE tells me that I cannot make reference of a non static method from a Static context (the Thread)

:S