How to retrieve values from the server without browser asking?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Neil_Attewell
Posted On:   Monday, July 28, 2008 08:25 AM

Hi All I am writing a chat program using jsp. What I want is to have the client's browser dynamically change the DOM by adding a Message to my output.html page. Currently I have my browser call every 2 seconds. //+ Servlet code snippet if( newMessages != null ){ String messages = newMessages; newMessages = null; return message; }else{ return null; } // - Servlet code snippet What I want to know is, is it possible to have my Servlet send the messages to the browser without having the browser ask Similar principal to JButton's ActionP   More>>

Hi All

I am writing a chat program using jsp.

What I want is to have the client's browser dynamically

change the DOM by adding a

Message



to my output.html page.
Currently I have my browser call

every 2 seconds.

//+ Servlet code snippet

if( newMessages != null ){

String messages = newMessages;

newMessages = null;

return message;

}else{

return null;

}

// - Servlet code snippet


What I want to know is,

is it possible to have my Servlet send the messages

to the browser without having the browser ask

Similar principal to JButton's ActionPerformed Event in Java?

Where Servlet triggers the event and Ajax is the listener



Thanx all in advance    <<Less

Re: How to retrieve values from the server without browser asking?

Posted By:   Robert_Lybarger  
Posted On:   Monday, July 28, 2008 06:38 PM

In a word: no. The entire *point* of the web infrastructure is that the client always asks for something first. You can side-step this, to some degree, with a Java applet or something along that line running in the page, but the server cannot push html to any client w/o a request going in first.
About | Sitemap | Contact