Forum Moderators: open

Message Too Old, No Replies

Rotate dynamic content in JSP

         

xaria

2:35 am on Jan 6, 2009 (gmt 0)

10+ Year Member



I have a jsp, which should rotate some content after every 10 secs.
The content is drwan from database, How can I rotate it without refreshing the page?

coopster

2:56 pm on Jan 7, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, xaria.

Do you mean jsp or JavaScript? Two very different applications.

xaria

2:41 am on Jan 8, 2009 (gmt 0)

10+ Year Member



I meant JSP. The reason I am posting in this forum is because I think rotation of content id achievable via javascript and Ajax, however the content needs to be displayed in a JSP page.

coopster

4:48 pm on Jan 8, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You can rotate content in a number of ways but if the content is not already delivered with the first request for the page it obviously cannot be in a rotation without a round trip to the server. JavaScript could be used exclusively to rotate that content if it was all delivered in the first request.

We'll go on the assumption that you are not delivering all the content for the rotation in the first request. So, we need to make a round trip to the server to get the next chunk of content for rotation. If you only want to replace a certain part of the page then you are describing what is commonly known as AJAX. You initiate a request to your JSP processing page using JavaScript and receive that request again with JavaScript and update your page with the latest information.

The request is often called an XMLHttpRequest and a quick search will turn up plenty of reading on the topic. Firefox has a starter page as well, I'll link it here for you ...
[developer.mozilla.org...]