Home | | Internet & World Wide Web HOW TO PROGRAM | | Internet Programming | | Web Programming | Case Study: Active Server Pages and XML

Chapter: Internet & World Wide Web HOW TO PROGRAM - Active Server Pages (ASP)

| Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail |

Case Study: Active Server Pages and XML

In this chapter, we use XML and ASP to create one of the most popular types of Web sites—a message forum. Message forums are “virtual” bulletin boards where various topics are discussed.

Chaptere 26

Case Study: Active Server Pages and XML

 

1. Introduction

 

In this chapter, we use XML and ASP to create one of the most popular types of Web sites—a message forum. Message forums are “virtual” bulletin boards where various topics are discussed. Common features of message forums include discussion groups, questions and answers and general comments. Many Web sites host message forums. For example,

 

messages.yahoo.com/index.html

web.eesite.com/forums

www.deja.com

 

are popular sites that host message forums.

 

In the case study presented in this chapter, users can post messages and create new forums. We leave the removal of a forum as an exercise for the reader.

 

 

2. Setup and Message Forum Documents

 

In this section, we provide the setup instructions for executing the case study. The case study requires the following software:

 

         Microsoft Internet Information Services (IIS) or Microsoft Personal Web Server (PWS).

 

         Internet Explorer 5.5 (for XML and XSLT processing).

 

         msxml 3.0 or higher. Visit www.deitel.com for download and installation in-structions.

 

Copy the files from the Chapter 26 examples directory (on the CD-ROM that accom-panies this book) to the Web directory (e.g., c:\inetpub\wwwroot). [Note: Either IIS or PWS must be installed; otherwise, this Web directory will not exist. This directory must also have Write permissions to allow users to post messages and add forums. The version presented in this chapter is IIS specific. PWS users should use the version in the examples directory in the PWS folder.] Each of these files and documents is summarized in Fig. 26.1 and will be discussed later in the chapter.

 

 

The main page, default.asp, displays the list of available message forums, which are stored in the XML document forums.xml. Hyperlinks are provided to each XML message forum document and also to addForum.asp, which adds a forum to forums.xml and creates a new XML message forum (e.g., forum2.xml), using the message forum template template.xml.

Each XML message forum document (e.g., forumASP.xml) is transformed into an XHTML document using the XSLT document formatting.xsl. The CSS document site.css formats the XHTML for display. New messages are posted to a forum by addPost.asp. If errors occur when the document is processed, invalid.html is dis-played. Some of these key interactions between documents are illustrated in Fig. 26.2.

 

 

 

3. Forum Navigation

 

This section introduces the documents that organize and display the message forums. Fig-ure 26.3 lists the XML document (forums.xml) that marks up each message forum.

 

Root element forums can hold any number of message forums. We provide an initial forum named forumASP.xml. An individual message forum is marked up, using element forum. Attribute filename stores the name of the XML document that contains the forum’s markup. We will discuss how this XML document is manipulated momentarily.

 

Figure 26.4 shows the Active Server Page (default.asp) that displays the list of message forums contained in forums.xml. CSS document site.css is applied to the XHTML sent to the Web browser.

 

Line 27 gets the absolute path for the file forums.xml and stores it in variable str-Path. Microsoft’s XML parser (i.e., msxml) requires an absolute path. Line 29 calls the Server object’s CreateObject method to instantiate a DOMDocument object (Microsoft.XMLDOM) and assigns the object to xmlFile. The DOMDocument object is the document root of an XML document.

 


 

            <?xml version = "1.0"?>

            <!-- Fig. 26.3 : forums.xml -->

            <!-- Creating the ASP forum -->

           

            <forums>

           

            <forum filename = "forumASP.xml">ASP</forum>

 

            </forums>

            <% @LANGUAGE = "VBScript" %>

 

 

            <% ' Fig. 26.4 : default.asp

            ' Forum home page

            Option Explicit

            %>

 

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 

            <html xmlns = "http://www.w3.org/1999/xhtml">

 

 

            <head>

            <title>Deitel Message Forums</title>

            <link rel = "stylesheet" type = "text/css"

            href = "style.css" />

            </head>

           

            <body>

            <h1>Deitel Message Forums</h1>

            <p><strong>Available Forums</strong></p>

            <ul>

 

            <%

            Dim xmlFile, xmlNodes, xmlItem

            Dim strPath, strTitle, strFileName

           

            strPath = Server.MapPath( "forums.xml" )

 

 

            Set xmlFile = Server.CreateObject( "Microsoft.XMLDOM" )

            xmlFile.Async = False

 

            If Not xmlFile.Load( strPath ) Then

            Call Server.Transfer( "invalid.html" )

            End If

 

            Set xmlNodes = xmlFile.DocumentElement.ChildNodes

 

            For Each xmlItem In xmlNodes

            strFileName = xmlItem.getAttribute( "filename" )

            strTitle = xmlItem.text

            %>

            <li>

            <a href = "<% =strFileName %>"><% =strTitle %></a>

            </li>

            <%

            Next

            %>

            </ul>

           

            <p><strong>Forum     Management</strong></p>

                       

            <ul>    

            <li><a href =   "addForum.asp">Add a Forum</a></li>

            <li>Delete a Forum</li>

            </ul>

 

            </body>

 

            </html>


 

Fig. 26.4 Message forums main page

 

 

Line 30 sets the object referenced by xmlFile to behave synchronously (i.e., when a method is called, it must finish executing before any other method is allowed to execute). We will explain the significance of setting Async to False momentarily.

 

Lines 32–34 call method Load to parse the XML document (e.g., forums.xml). If parsing succeeds, True is returned; otherwise, False is returned. Because xmlFile is synchronous, execution does not continue until method Load completes. If method calls are not synchronous (i.e., they are asynchronous), execution continues despite the fact that the method may not have finished executing, which could result in logic errors (i.e., the code does not execute as intended). If parsing fails, we redirect the browser to invalid.html, which is discussed in Section 26.7.

 

Line 36 uses property DocumentElement to get the root element’s child nodes. Ele-ment nodes have property ChildNodes, which returns a collection (e.g., a list) of the ele-ment node’s child nodes.

 

Lines 38–46 contain a For Each loop that iterates through all the nodes in the collec-tion of child nodes stored in xmlNodes. Line 39 calls method getAttribute to get a forum’s filename. This method returns the value of the node’s filename attribute and assigns it to strFileName. Line 40 uses property text to return the node’s text content, which is the forum’s name.

 

Line 43 writes, as an anchor, the value of strFileName and writes the value of strTitle to describe the anchor. This creates the hyperlinks for the available forums. Each hyperlink references an XML document. For example, the ASP forum references forumASP.xml.

 

Line 53 provides a hyperlink to addForum.asp, which adds a new forum and is dis-cussed in the next section. Line 54 is a placeholder for a link to delete forums, which is left to the reader as an exercise.

 

4. Adding Forums

 

In this section, we discuss the documents used to add new forums. Each new forum created is based upon a template XML document named template.xml (Fig. 26.5).

 

This template document contains the bare components for a message forum. It contains a stylesheet processing instruction that references formatting.xsl (discussed in Fig. 26.8) and <forum> tags. The Active Server Page (addForum.asp) that modifies the template document is presented in Fig. 26.6. [Note: Actually, the copy of the template document loaded into memory is modified and saved to disk with a different name.]

 

 

1   <?xml version = "1.0"?>

 

2

3   <!-- Fig. 26.5 : template.xml -->

4   <!-- Template XML document        -->

 

5

6   <?xml:stylesheet type = "text/xsl" href = "formatting.xsl"?>

 

7

    <forum>

    </forum>

 

Fig. 26.5       Template for message forum XML documents.

 

 

    <% @LANGUAGE = "VBScript" %>

    <% Option Explicit %>

    <% ' Fig. 26.6 : addForum.asp %>

 

    <%

    Dim xmlFile, xmlRoot, xmlNode

Dim strTitle, strError, strPath

If Request( "submit" ) <> Empty Then

 

If Request( "name" ) <> Empty And _

Request( "filename" ) <> Empty And _

Request( "user" ) <> Empty And _

Request( "title" ) <> Empty And _

Request( "text" ) <> Empty Then

 

' Create a new XML file

strPath = Server.MapPath( Request( "filename" ) )

 

Set xmlFile = Server.CreateObject( "Microsoft.XMLDOM" )

xmlFile.Async = False

 

If xmlFile.Load( strPath ) Then

Call Server.Transfer( "invalid.html" )

End If

 

' set up the file

Call xmlFile.Load( Server.MapPath( "template.xml" ) )

 

' get the root element

Set xmlRoot = xmlFile.DocumentElement

 

 

' set the filename

Call xmlRoot.SetAttribute( "filename", _

Request( "filename" ) )

 

' create Name node

Set xmlNode = xmlFile.CreateElement( "name" )

xmlNode.Text = Request( "name" )

Call xmlRoot.AppendChild( xmlNode )

 

' create first message

Set xmlNode = xmlFile.CreateElement( "message" )

Call xmlNode.SetAttribute( "timestamp", Now & " EST" )

Call xmlRoot.AppendChild( xmlNode )

 

Set xmlRoot = xmlNode

 

' create user node

Set xmlNode = xmlFile.CreateElement( "user" )

xmlNode.Text = Request( "user" )

Call xmlRoot.AppendChild( xmlNode )

 

' create title node

Set xmlNode = xmlFile.CreateElement( "title" )

xmlNode.Text = Request( "title" )

Call xmlRoot.AppendChild( xmlNode )

 

' create text node

Set xmlNode = xmlFile.CreateElement( "text" )

xmlNode.Text = Request( "text" )

Call xmlRoot.AppendChild( xmlNode )

 

Call xmlFile.Save( strPath ) ' save the file

 

' load XML file

strPath = Server.MapPath( "forums.xml" )

 

Set xmlFile = Server.CreateObject( "Microsoft.XMLDOM" )

xmlFile.Async = False

 

If Not xmlFile.Load( strPath ) Then

Call Server.Transfer( "invalid.html" )

End If

 

' get the root node

Set xmlRoot = xmlFile.DocumentElement

 

' create nodes

Set xmlNode = xmlFile.CreateElement( "forum" )

Call xmlNode.SetAttribute( "filename", _

Request( "filename" ) )

xmlNode.Text = Request( "name" )

Call xmlRoot.AppendChild( xmlNode )

 

Call xmlFile.Save( strPath ) ' save the file

 

' finished processing

            Call Server.Transfer( "default.asp" )

            Else

            strError = "ERROR: Invalid input."

            End If

 

            End If

            %>

 

            <!DOCTYPE html

            PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

           

            <html xmlns = "http://www.w3.org/1999/xhtml">

            <head>

            <title>Add a Forum</title>

            <link rel = "stylesheet" type = "text/css" href = "style.css" />

            </head>

 

                        <body>

            <p>Create a Forum</p>

            <p><% =strError %></p>

           

            <form method = "post" action = "addForum.asp">

 

 

            <h2>

            Forum Name:<br />

            <input type = "text" size = "40" name = "name"

            value = "<% =Request( "name" ) %>" />

            </h2>

 

            <h2>

            Forum File Name:<br />

            <input type = "text" size = "40" name = "filename"

            value = "<% =Request( "filename" ) %>" />

            </h2>

 

            <h2>

            User:<br />

            <input type = "text" size = "40" name = "user"

            value = "<% =Request( "user" ) %>" />

            </h2>

 

            <h2>

            Message Title:<br />

            <input type = "text" size = "40" name = "title"

            value = "<% =Request( "title" ) %>" />

            </h2>

 

            <h2>

            Message Text:<br />

            <textarea name = "text" cols = "40"

            rows = "4"><% =Request( "text" ) %></textarea>

            </h2>

 

            <h2>

            <input type = "submit" name = "submit" value = "Submit" />

            <input type = "reset" value = "Clear" />

            </h2>

 

            </form>

 

 

            <p>

            <a href = "default.asp">Return to Main Page</a>

            </p>

 

            </body>

 

            </html>

 


Fig. 26.6       Page to add to a forum

 

This Active Server Page performs two tasks: First, it displays the form that gets the new forum’s information (lines 98–149). Second, it provides the script for creating the forum (lines 1–96). We will discuss the form for getting information first.

 

Line 110 writes strError’s content to the Web browser. Error messages, if they exist, are stored in strError. Lines 112–149 create a form to post information back to addForum.asp. The form has fields for the forum name, forum file name, user name, message title and message text. The Request object is used to retrieve the submitted form’s value.

 

We will now discuss the script logic for the page. Line 10 determines whether the form was submitted by testing the form’s submit field for a value. If the submit field is Empty, then the form was not submitted.

 

Lines 12–16 check the form’s fields for values. If any of the fields is Empty, the infor-mation for the new forum is incomplete, and line 92 sets strError to "ERROR: Invalid input.".

 

Lines 24–26 attempt to load the file specified by the user. [Note: The name specified in the Forum File Name must end in .xml.] If the file loads successfully, then the file already exists. Therefore, we transfer to invalid.html. Remember, we want to add a new forum, not open an existing one.

 

Line 29 loads the template XML document (i.e., template.xml). We will mark up the form’s data and add the data to the in-memory representation of template.xml.

 

Lines 35–36 call method SetAttribute to create an attribute node named file-name that has the value contained in form field filename. Line 39 creates a new element node named name, using DOMDocument method CreateElement.

Line 40 assigns form field name’s value to the element node’s (created in line 39) Text property. Line 41 calls method AppendChild to append the newly created element name node to the root element (i.e., forum).

 

Lines 44–46 create and append element message, along with attribute timestamp, to the root element forum. Lines 51–53 create and append element user to element mes-sage. Lines 56–58 create and append element title, and lines 61–63 create and append element text to the root element.

 

Line 65 saves the XML document to disk by calling method Save. Variable str-Path contains the filename provided by the user in line 19. Lines 68–87 open, modify (by adding the new forum just created) and save forums.xml.

 

5. Forum XML Documents

 

This section presents a sample forum (Fig. 26.7) that contains several messages and the XSLT document (Fig. 26.8) that transforms it into XHTML.

 

Lines 48–53 write an <a> tag to the result tree. XSLT element xsl:attribute cre-ates an attribute named href for element a and assigns it the value of attribute filename concatenated to addPost.asp?file=.

 

            <?xml version = "1.0"?>

 

 

            <!-- Fig. 26.7 : forumASP.xml -->

            <!-- Postings on ASP forum   -->

 

 

            <?xml:stylesheet type = "text/xsl" href = "formatting.xsl"?>

 

 

            <forum filename = "forumASP.xml">

 

 

            <name>ASP Forum</name>

 

 

            <message timestamp = "4/28/2001 2:50:34 PM EST">

            <user>D. Bug</user>

            <title>I Love ASP!</title>

            <text>Everyone should use ASP.</text>

            </message>

 

            <message timestamp = "5/8/2001 11:09:54 AM EST">

            <user>Ms. Quito</user>

            <title>ASP and XML</title>

            <text>What a powerful combination. Try it!</text>

            </message>

 

            <message timestamp = "5/15/2001 4:39:50 PM EST">

            <user>Sarge Ant</user>

            <title>ASP</title>

            <text>This <em>army ant</em> uses ASP in boot camp.</text>

            </message>

 

            </forum>

Fig. 26.7       Sample forum.

 

            <?xml version = "1.0"?>                                

                                               

            <!-- Fig. 26.8 : formatting.xsl -->      

            <!-- XSL document that transforms XML data to XHTML -->       

                                               

            <xsl:stylesheet version = "1.0"

            xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">

           

            <xsl:output method = "html" omit-xml-declaration = "no"

            doctype-system =

            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"

            doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN" />

           

            <xsl:template match = "/">

 

 

            <html xmlns = "http://www.w3.org/1999/xhtml">

            <xsl:apply-templates select = "*" />

            </html>

           

            </xsl:template>

           

            <xsl:template match = "forum">

           

            <head>

            <title><xsl:value-of select = "name"/></title>

            <link rel = "stylesheet" type = "text/css"

            href = "style.css" />

            </head>

           

            <body>

           

            <table width = "100%" cellspacing = "0"

            cellpadding = "2">

            <tr>

            <td class = "forumTitle">

            <xsl:value-of select = "name" />

            </td>

            </tr>

            </table>

           

            <table width = "100%" cellspacing = "0"

            cellpadding = "2">

            <xsl:apply-templates

            select = "message" />

            </table>

 

            <p>

            <a>

            <xsl:attribute

            name = "href">addPost.asp?file=<xsl:value-of

            select = "@filename" />

            </xsl:attribute>

            Post a Message</a><br />

            <a href = "default.asp">Return to Main Page</a>

            </p>    

                       

            </body>         

                       

            </xsl:template>          

                       

            <xsl:template match = "message">    

                       

            <tr>    

            <td class = "msgTitle">          

            <xsl:value-of select = "title" />          

            </td>  

            </tr>   

                       

            <tr>    

            <td class = "msgInfo">          

            by       

            <em><xsl:value-of select = "user" /></em>

            at        

            <span class = "date"> 

            <xsl:value-of select = "@timestamp" />

            </span>          

            </td>  

            </tr>   

                       

            <tr>    

            <td class = "msgText">          

            <xsl:value-of select = "text" />          

            </td>  

            </tr>   

                       

                       

            </xsl:template>          

                       

</xsl:stylesheet>        

 

Fig. 26.8 XSLT to transform XML forum document into HTML

 

Figure 26.9 shows the XHTML document rendered by Internet Explorer 5.5 when forumASP.xml is transformed by formatting.xsl. [Note: We have edited the XHTML document for presentation purposes.] Line 66 provides a link to addPost.asp, along with the name of the file to which the new message will be added.

 

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 

 <!-- Fig. 26.9 : forumASP_transformed.html --> 5 <!-- Results of transforming forumASP.xml -->

 

 

    <html xmlns = "http://www.w3.org/1999/xhtml">

 

 

    <head>

    <title>ASP Forum</title>

    <link href = "site.css" type = "text/css" rel = "stylesheet" />

    </head>

 

    <body>

    <table cellpadding = "2" cellspacing = "0" width = "100%">

    <tr>

    <td class = "forumTitle">ASP Forum</td>

    </tr>

    </table>

   

    <table cellpadding = "2" cellspacing = "0" width = "100%">

    <tr>

    <td class = "msgTitle">I Love ASP!</td>

    </tr>

    <tr>

    <td class = "msgInfo">

    by

    <em>D. Bug</em>

    at

    <span class = "date">4/28/2001 2:50:34 PM EST</span></td>

    </tr>

    <tr>

    <td class = "msgText">Everyone should use ASP.</td>

    </tr>

    <tr>

    <td class = "msgTitle">ASP and XML</td>

    </tr>

    <tr>

    <td class = "msgInfo">

    by

    <em>Ms. Quito</em>

    at

    <span class = "date">5/8/2001 11:09:54 AM EST</span></td>

    </tr>

    <tr>

    <td class = "msgText">

    What a powerful combination. Try it!</td>

    </tr>

    <tr>

    <td class = "msgTitle">ASP</td>

    </tr>

    <tr>

    <td class = "msgInfo">

    by

    <em>Sarge Ant</em>

    at

    <span class = "date">5/15/2001 4:39:50 PM EST</span></td>

    </tr>

    <tr>

    <td class = "msgText"> 

    This army ant uses ASP in boot camp.</td>

    </tr>

    </table>

   

    <p>

    <a href = "addPost.asp?file=forumASP.xml">Post a Message</a>

    <br>

    <a href = "default.asp">Return to Main Page</a>

    </p>

 

    </body>

 

 

    </html>

 


 

Fig. 26.9 Output of the transformation of the forum XML document

 

 

6. Posting Messages

 

In this section, we present the ASP document addPost.asp (Fig. 26.10), which posts messages to a forum. This ASP uses much of the same functionality as addForum.asp.

 

Line 23 loads the forum XML document. Lines 31–33 create a message element and an associated timestamp attribute. Line 38 creates child element user; line 41 creates child element title; and line 44 creates child element text for element message. Finally, the forum is saved to disk in line 46.

 

 

            <% @LANGUAGE = "VBScript" %>

 

            <% ' Fig. 26.10 : addPost.asp

            ' ASP document for posting a message

           

            Option Explicit

 

            Dim xmlFile, xmlRoot, xmlNode

            Dim strTitle, strError, strPath

           

            If Request( "submit" ) <> Empty Then

           

            If Request( "file" ) <> Empty And _

            Request( "userName" ) <> Empty And _

            Request( "messageTitle" ) <> Empty And _

            Request( "messageText" ) <> Empty Then

           

            strPath = Server.MapPath( Request( "file" ) )

           

            Set xmlFile = Server.CreateObject( "Microsoft.XMLDOM" )

            xmlFile.Async = False

           

            If Not xmlFile.Load( strPath ) Then

            Call Server.Transfer( "invalid.html" )

            End If

           

            ' get the root node

            Set xmlRoot = xmlFile.DocumentElement

           

            ' create first message

            Set xmlNode = xmlFile.CreateElement( "message" )

            Call xmlNode.SetAttribute( "timestamp", Now & " EST" )

            Call xmlRoot.AppendChild( xmlNode )

           

            Set xmlRoot = xmlNode

           

            ' create user node

            Call CreateElementNode( "user", "userName", xmlNode )

           

            ' create title node

            Call CreateElementNode( "title", "messageTitle", xmlNode )

           

            ' create text node

            Call CreateElementNode( "text", "messageText", xmlNode )

           

            Call xmlFile.Save( strPath ) ' save the file

           

            ' finished processing

            Call Server.Transfer( Request( "file" ) )

            Else

            strError = "ERROR: Invalid input."

            End If

            End If

                       

            ' procedure that creates an element node

            Sub CreateElementNode( elementName, formElement, node )

            Set xmlNode = xmlFile.CreateElement( elementName )

            xmlNode.Text = Request( formElement )

            Call xmlRoot.AppendChild( node )

            End Sub

            %>

 

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 

            <html xmlns = "http://www.w3.org/1999/xhtml">

            <head>

            <title>Post a Message</title>

            <link rel = "stylesheet" type = "text/css"

            href = "style.css" />

            </head>

           

            <body>

            <p><% =strError %></p>

           

            <form method = "post" action = "addPost.asp">

            <p>

            User:<br />

            <input type = "text" size = "40" name = "userName"

            value = "<% =Request( "userName" ) %>" />

            </p>

           

            <p>

            Message Title:<br />

            <input type = "text" size = "40" name = "messageTitle"

            value = "<% =Request( "messageTitle" ) %>" />

            </p>

           

            <p>

            Message Text:<br />

            <textarea name = "messageText" cols = "40"

            rows = "4"><% =Request( "messageText" ) %>

            </textarea>

            </p>

           

            <p>

            <input type = "hidden" name = "file"

            value = "<% =Request( "file" ) %>"/>

            <input type = "submit" name = "submit" value = "Submit" />

            <input type = "reset" value = "Clear" />

            </p>

            </form>

 

            <p>

            <a href = "<% =Request( "file" ) %>">Return to Forum</a>

            </p>

            </body>

           

            </html>


Fig. 26.10  Adding a message to a forum

 

Figure 26.11 shows a new forum (i.e., Internet and World Wide Web: 2nd Edi-tion) added to the message board, while Fig. 26.12 shows the initial content of that forum.



 

7. Other Documents

 

In this section, we present three other documents used in the case study. Figure 26.14 lists the XHTML document that displays an error message (invalid.html).


 

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 

 <!-- Fig. 26.14 : invalid.html --> 5 <!-- XHTML document for displaying errors -->

 

            <html xmlns = "http://www.w3.org/1999/xhtml">

 

            <head>

            <title>Deitel Book Organization</title>

            <link rel = "stylesheet" type = "text/css"

            href = "site.css" />

            </head>

 

            <body>

            <h1>Invalid Request.</h1>

           

            <p><a href = "default.asp">Return to Main Page</a></p>

            </body>

 

            </html>

Fig. 26.14  Document that displays an error message.

 

Figure 26.15 lists the CSS document (site.css) that formats the XHTML documents. Figure 26.16 lists the CSS document that formats the forum (style.css)

 

            /*         Fig. 26.15        : site.css           */

            /*         Stylesheet        for XHTML documents */

    body

    {

    background: white;

    color: black;

    font-family: Arial, sans-serif;

    font-size: 10pt;

      }

      a

      {

      background: transparent;

      color: blue;

      text-decoration: none;

      }

      a:hover

      {

      text-decoration: underline;

      }

      table

{

      border-width: 1px;

      border-style: solid;

      }

      .forumTitle

      {

      background: lime;

      color: black;

      font-size: 12pt;

      font-weight: bold;

      text-align: center;

      }

      .msgTitle

      {

      background: silver;

      color: black;

      font-size: 10pt;

      font-weight: bold;

      }

      .msgInfo

      {

      background: silver;

      color: black;

      font-size: 10pt;

      }

      .msgPost

      {

      background: silver;

      color: black;

      font-size: 8pt;

      }

      .msgText

      {

      font-size: 10pt;

      padding-left: 10px;

      }

      .date

      {

      font-size: 8pt;

}

    h1

    {

    color: #330099;

    letter-spacing: 2px;

    font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;

    background-color: transparent;

    }

    h2

      {

      color: #6633FF;

      font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;

      font-size: small;

      background-color: transparent;

      }

      p

      {

      font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;

      color: #336666;

      letter-spacing: 1px;

      font-size: larger;

      font-weight: bold;

      background-color: transparent;

      }

      body

      {

      background-image: url(bug2.gif);

      background-repeat: no-repeat;

      margin-top: 5%;

      background-position: 25%;

      margin-left: 10%;

      }

      li

      {

      font-family: "Courier New", Courier, monospace;

      font-weight: bolder;

      list-style-type: circle;

      color: #3333FF;

      background-color: transparent;

      }

      input

      {

      background-color: transparent;

      color: #336666;

      font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;

      }

      textarea

{

 

      background-color: transparent;

      color: #336666;

      font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;

      }

      .forumTitle

      {

      color: #FFFFCC;

      font-size: 14pt;

      font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;

      text-align: center;

      background-color: #6666CC;

      }

      .msgTitle

      {

      background: #FFFFCC;

      color: black;

      font-size: 10pt;

      font-weight: bold;

      }

      .msgInfo

      {

      background: #FFFFCC;

      color: black;

      font-size: 10pt;

      }

      .msgPost

      {

      background: silver;

      color: black;

      font-size: 8pt;

      }

      .msgText

      {

      font-size: 10pt;

      padding-left: 10px;

      }

 

      .date

      {

      font-size: 8pt;

}

 

 

Fig. 26.16  CSS document for forums

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail


Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.