aspose file tools*
The moose likes Servlets and the fly likes Dynamic content in HTML Pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Dynamic content in HTML Pages" Watch "Dynamic content in HTML Pages" New topic
Author

Dynamic content in HTML Pages

Prabhakar Rao
Ranch Hand

Joined: Aug 23, 2006
Posts: 40
How the sites are displaying Dynamic content in HTML pages.
Suppose if we take index.html of rediff, each time you refresh the page it shows a different ad.

Please explain the topic in deatil.

Thanks in advance
-Prabhakar
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

Could be using some simple Javascript.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Prabhakar Rao
Ranch Hand

Joined: Aug 23, 2006
Posts: 40
Thanks for that

But I need the actual process on
-how they put space for the dynamic content.
-how they display dynamic content each time.
Will be thankful if you can provide some code demonstration.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

They may not be static HTML pages either.
Most server side technologies provide a way to map url strings to dynamic content. Something like "mypage.html" could actually be pointing to a PHP page or Cold Fusion app.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
sven studde
Ranch Hand

Joined: Sep 26, 2006
Posts: 148
Originally posted by Prabhakar Rao:
How the sites are displaying Dynamic content in HTML pages.
Suppose if we take index.html of rediff, each time you refresh the page it shows a different ad.

What does "of rediff" mean?

I agree with Bear and Ben. Displaying a different ad on a page everytime the page is loaded can be accomplished on the client side with simple javascript or it can be accomplished on the server side using a server side language like php or servlets + jsp.

But I need the actual process on
-how they put space for the dynamic content.

It sounds like you might need to learn some html as well. Web browsers render html in the order it appears on the page (although that order can be altered using css). Also, you can use css to make text on a web page flow around any sized image automatically, so the size of the image would be irrelevant.

-how they display dynamic content each time.

You populate an array with different .jpg files that are ads. When the request is received, you program the jsp or servlet to generate a random integer and assign it to a variable. You use that variable as the index value of the array, e.g.

myAds[myRanNum]

and then you assign that specific .jpg file to the src attribute of an <img> tag, e.g.

out.println("<h1>My Web Page</h1>");
out.println("<img src=\"http://mysite.com/someDir/ads/" + myAds[myRanNum] + "\"/>");
out.println("<div>some text here</div>");

[ October 05, 2006: Message edited by: sven studde ]
Kartik Patel
Ranch Hand

Joined: Sep 12, 2005
Posts: 73
Another way of creating dynamic html is through XML/XSLT.
You create an dynamic XML and parse it through XSLT toi generate html page.
the page will have dynamic data and its still an html page.


Chop your own wood, and it will warm you twice. - Henry Ford
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
If you mean to change the content and add some functionality after a HTML has been rendered , then you might use javascript.Using AJAX you can even send HTTPXMLRequest to server and manupulate the response data at the client side using javascript.Is that you want ?


Rahul Bhattacharjee
LinkedIn - Blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dynamic content in HTML Pages