Serving Web Pages with Dynamic Data

an article added by: Daniel R. at 12062007


In: Root » » Ethernet » Serving Web Pages with Dynamic Data

French Spanish Portuguese Italian German Japanese Chinese Korean Russian Arabic

Serving Web Pages with Dynamic Data

Because embedded systems almost always serve Web pages that contain dynamic, or real-time, information, this networking tutorial begins with Rabbit and TINI examples that serve Web pages with dynamic content. Following the examples is an introduction to using HTTP and other protocols in serving Web pages.

Two Approaches

A Web browser such as Microsoft’s Internet Explorer is a client application that uses HTTP to request Web pages from servers on the Internet or in a local network. The servers don’t have to be PCs or other large computers. Even a small embedded system with limited memory can serve a page containing text and simple images, including pages that display real-time data and accept and act on user input. A browser provides a user interface for requesting and displaying pages. The computers that request Web pages typically have full-screen displays, but for some applications, an embedded system with limited display capabilities can function as an HTTP client. If the requested pages are very simple, even a text-only display of a few lines might suffice. Or an embedded system might receive and process the contents of a Web page without displaying the page in a browser at all. This networking tutorial focuses on Web servers. With an Internet connection, a Web server can serve pages to any browser on the Internet. Or a server may be programmed to respond to requests only from specific IP addresses. A Web server in a local network may serve pages to selected computers or to any computer in the local network.

An embedded system that functions as a Web server generally has all of the following:

• Non-volatile memory to hold pages to be served.

• Support for TCP and IP. Requests for Web pages and the pages sent in response travel in the data portion of TCP segments.

• Support for HTTP. The server must be able to understand and respond to received requests for Web pages. The HTTP standard specifies the format for the requests and replies.

• A local-network or Internet connection. To serve pages on the Internet, the Web server must have an Internet connection. Any firewalls must be configured so the system can receive HTTP requests, as described in Chapter 10.

• One or more pages to serve. The Web pages are files or blocks of text that use a form of encoding called hypertext markup language (HTML).

The HTML encoding specifies the formatting of text and images on the page, including text size and fonts and the positioning of text and other elements on the page. The HTML code may include links to images that appear on the page, as well as links to other pages or resources. In serving a Web page with dynamic content, the software must have a way of inserting the dynamic content as the page is being served. A variety of protocols and technologies can work along with HTTP and HTML to enable a server to provide Web pages that contain real-time data and respond to user input. This networking tutorial includes two approaches to serving real-time data, and Chapter 7 covers ways that Web servers can respond to user input.

Serving a Page with Dynamic Data

Many Web pages are static, where the information on the page doesn’t change unless someone edits the page’s HTML file and uploads the new file to the server. Static Web pages are useful for presenting product information, articles, or other information that remains constant. But most embedded systems have little use for static pages, other than possibly presenting a home page with links to other pages. An embedded system that functions as a Web server will almost certainly want to display real-time information such as sensor readings or other up-to-the-minute information about the processes or environments the system is controlling or monitoring.

This section shows how the Rabbit and TINI modules introduced in Chapter 3 can serve Web pages that display dynamic data. Dynamic, or real-time, data includes any data that can change over time and can be different each time the page is served. An obvious example is a counter that displays the number of times the page has been accessed. Dynamic data may also include sensor or switch readings and time and date information. The supporting code included with the Rabbit and TINI (and additional sources in the case of Java servlets on the TINI) greatly reduces the amount of the programming required to serve Web pages with dynamic content. The dynamic data served by the example applications in this networking tutorial consists of a message that displays the amount of time the system or application has been up and running. Network article 6-1 shows an example page. The embedded system stores the number of days, hours, minutes, and seconds in variables. When serving the page, the server application inserts the current values of the variables in the appropriate places in the page. You can use the same techniques to create Web pages that display the current values of any variables in a system. Although the result is the same, the Rabbit and TINI examples use different approaches to achieve the result. The Rabbit uses Server Side Include directives that instruct the server to insert the values of variables in the appropriate locations in the file being served. For the TINI, instead of storing the Web page in a separate file, the application creates the Web page as it’s being sent, using a series of writes to send the page’s contents to a TCP socket and inserting the values of variables in the designated locations in the page.

legal disclaimer

Our website is not responsible for the information contained by this article. Web-articles is a free articles resource.
Suggestion: If you need fresh, daily updated content for your website, feel free to use our service. Click here for more information.

related articles

1. Dallas Semiconductor DSTINIm400
Dallas Semiconductor DSTINIm400 (TINI) At a Glance: A fast microcontroller with an enhanced 8051 architecture, plenty of I/O, an operating system, and a Java virtual machine (JVM). Ethernet support: 10BASE-T, 100BASE-TX Typical Uses: applications that need speed, lots of I/O, or a CAN interface. Source: Dallas Semiconductor (www.dalsemi.com). Dallas Semiconductor is a wholly owned subsidiary of Maxim Integrated Products. Hardware. TINI stands for Tiny InterNet Interface. Technically, the TINI isn’t a ...

2. The MCF5282 supports a subset of the Motorola 68000
Ethernet support: 10BASE-T The MCF5282 supports a subset of the Motorola 68000. Typical use: Applications that use Java and require speed. Source: Systronix (www.systronix.com). Hardware. The TINI isn’t the only option for Java programmers. Systronix’s JStik board (Network article 3-8) contains aJ-100 microcontroller from aJile Systems Inc. The aJ-100’s native execution of Java bytecodes results in very fast performance. The chip is base...

3. Ubicom IP2022 Wireless Network Processor
Special-Purpose Modules Ubicom IP2022 Wireless Network Processor. In addition to products that provide a complete generic system for networking, a variety of modules and chips are available to handle specific tasks. Some products can interface to just about any CPU. If you have an existing product or a CPU that you want to use, one of these modules may provide a way to add networking capability. This section describes a selection of products. Lantronix Device Server At a glance: enables any device with an ...

4. EDTP Electronics Packet Whacker
EDTP Electronics Packet Whacker At a glance: An Ethernet interface on a circuit board with headers for connecting to a CPU. Typical use: adding Ethernet to any microcontroller circuit. Ethernet support: 10BASE-T Source: EDTP Electronics (www.edtp.com) Hardware. The Packet Whacker (Network article 3-11) from EDTP Electronics is an Ethernet interface only. The circuit board contains a Realtek RTL8019AS Ethernet controller, an RJ-45 connector, two headers that bring out the si...

5. NE2000 Compatibility
NE2000 Compatibility A term you’re likely to hear in reference to program code for network controllers is NE2000-compatible. The NE2000 was an early and popular PC network interface card from Novell. The card contained National Semiconductor’s DP8390 controller. Software for systems that use the ’8390 or a compatible chip has come to be known as NE2000-compatible code. A major feature of the ’8390 is its set of internal registers. By reading and writing to the registers, a CPU can c...

6. Using the Internet Protocol in Local and Internet Communications
The protocols in the IEEE 802.3 Ethernet standard enable the computers in a local network to exchange messages with each other. In practice, most Ethernet networks also use Internet protocols such as TCP or UDP and IP. These provide defined and well-supported methods for accomplishing common tasks such as flow control and flexible addressing and routing of messages. Messages that travel on the Internet must use IP. And because TCP and UDP are designed to work along with IP, local communications that use TCP or UDP also use...

7. There are several options for obtaining an Internet connection
Technologies for Connecting There are several options for obtaining an Internet connection. A long-popular way for home users to connect to the Internet is via dial-up connections on phone lines. For higher speeds, alternatives are a Digital Subscriber Line (DSL), an Integrated Services Digital Network (ISDN) line, or a cable modem. Satellite connections are also possible. Table 4-1 compares the capabilities of the different methods. Not every connection type is available in all locations. Depending on ...

8. Every computer that communicates over the Internet must have an IP address
Static and Dynamic IP Addresses Every computer that communicates over the Internet must have an IP address, which the computer typically receives from its ISP. The IP address may be static or dynamic. A static IP address stays the same until someone explicitly changes it, while a dynamic IP address can change on every boot up or network connect (though the address typically changes only occasionally). An embedded system may store a static IP address in non-volatile memory, either within an application...

9. Obtaining and Using a Domain Name
Obtaining and Using a Domain Name After you obtain Internet access, connect your embedded system to the Internet, and configure your firewall to enable the embedded system to communicate, the system is ready to send and receive messages on the Internet. Applications running on other computers on the Internet can access the embedded system by specifying its public IP address. For example, to view a server’s home page, in the Address text box of a Web browser, you enter http:// followed by the server&rsquo...