rockernerd
rockernerd

Reputation: 31

loading data from the database continuously in a jsp page

I am making a simple chat application using jsp and servlets. My problem is that the jsp page only shows the messages( which are stored in the database) on click of the submit button. As a result till the type user1 doesn't click submit, he can't see what user2 has typed. Can anyone suggest me a solution? Thanks in advance.

Upvotes: 0

Views: 850

Answers (2)

boisvert
boisvert

Reputation: 3739

Ajax: http://w3schools.com/ajax/

using javascript, you control the moment when the browser connects to the server to ask for data. It still is limited - you will update the chat e.g. every second.

Upvotes: 0

Craig Trombly
Craig Trombly

Reputation: 464

Think of this in terms of Client/Server. If your client is not "connected" to the server, which is the case of a browser, you need to "connect" it to the server to get updated messages or text. You can accomplish this a few ways with a client, either events or pooling a timer, even Push technology but that may be a little complex for a beginner to do. HTML5 has a way for registering for events, javascript could pool for new messages....

Upvotes: 1

Related Questions