How do I find out if a Web page is static?
How can I automatically test for interactivity of a Web site? In other words, sometimes the site is down, and there is just a static Web page at the address. When ITBS is working, users can type in query text and receive output from the database.

I want to write a program that will email me if the database is not up and running, as opposed to just having a static page that may be working fine.

    Requires Free Membership to View

    By submitting your registration information to SearchOracle.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchOracle.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

Mike Ault thanks Michael Cunningham for his help in responding to this question.

Here is a way to do this. This sample assumes the site is NOT https. For that the reader would need to read up on this package in Oracle document B10802-01. It also assumes the machine Oracle is on can make http requests from the Internet.

The anonymous block below looks at the Google site. On that site there is an HTML input item with the name of "q" (where the search text is typed in). The code below checks to see if the item with "name=q" exists on the HTML page. For the reader I would think he/she could do the same, but for a particular item on the page of the 'interactive' page mentioned. If the item does not exist on the page, then the text returned in the request is likely for a static page.

Also note: The http response is returned in a TABLE type. I'm only checking the first array item in the TABLE. If the http response is larger you would need to check more array items.

declare
   html_pieces utl_http.html_pieces; -- TABLE type each item is VARCHAR2(2000)
   n_length pls_integer;
begin
   html_pieces := utl_http.request_pieces( 'http://www.google.com/', 10 );
   n_length := instr( html_pieces(1), 'name=q' );
   if n_length <> 0 then
      dbms_output.put_line( 'Page is not static.' );
   else
      dbms_output.put_line( 'Page is static.' );
   end if;
end;
/

This was first published in September 2005

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.