When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search

Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs

















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs
Print this page.

Windows Systems Administrator
Jupitermedia
US-CT-Darien

Justtechjobs.com Post A Job | Post A Resume

Published: Tuesday, July 18, 2000

Speed up your ASP pages: Turn Them into HTML with ASPTear!
By Evagoras Charalambous


Let's face it: HTML is faster than ASP. Yes, we are hearing promises of compiled ASP+ code that will run a lot faster than today's ASP, but will it be faster than good old HTML? (To learn more about ASP+ be sure to check out our ASP+ Article Index.) As developers we often use ASP to connect to a database and display certain results. Whether we do it all with ASP, or with components it doesn't matter. The question on our minds is "how long does it take to process?". A good example of this is a messageboard where for every 10 visits you get only one post. It makes more sense to change it from an ASP page which requests a visit to the database every time to a plain HTML page and update the HTML page only when there is a new post. In this article I will show you a way to improve some of your ASP pages by transforming them into pure HTML using the free component ASPTear. (To learn more about ASPTear be sure to read the previous 4Guys article: Grabbing Information from Other Servers.)

- continued -

I will break down this example into 3 parts. In the first one I will show you how to use ASPTear to get the contents of another page, in the second part how to write the contents to an HTML file using the FileSystemObject, and in the third part I will put everything together using transactions to make sure they all get executed. (To learn more about the FileSystemObject be sure to take a moment and read the FileSystemObject F.A.Q..)

Part 1: Using ASPTear
The free component can be downloaded from http://www.alphasierrapapa.com/iisdev/components/asptear/ where you can also find instructions on how to register it on your server and use it. I will summarize the use of it here though. To instantiate the component you write:

Set xObj = Server.CreateObject("SOFTWING.ASPTear")
strRetVal = xObj.Retrieve(StrUrl, nRequestType, _
         strQueryString|strPostData, strUsername, strPassword)

This is a very simple component. It supports only one method: Retrieve. The rest here means:

ParameterMeaning
StrRetValThe HTML code returned back to us in the form of a string
StrUrlThe complete URL of the page you want to get
NRequestType2 for GET, 1 for POST
strQueryString|strPostDataany information you need to post to a page to aid it in the processing, just like posting data from a form or using the URL to add a querystring.
strUsername/strPasswordLog in to secured sites with username/password

The simplest form of this component could be something like this:

strRetVal = xObj.Retrieve("http://www.fakeaddress.com/default.asp",2,"","","")

or a more complicated one could be something like:

strPostData = "Name=" & Server.URLEncode("Christoph Wille") & _
      "&goto=" & Server.URLEncode("http://www.alphasierrapapa.com/")
strRetVal = xObj.Retrieve("http://www.alphasierrapapa.com/",1, _
                          strPostData,"Evagoras","Charalambous")

Ok let's get to work! We'll be creating a procedure that will run on the server and will do all this for us. I call this procedure CreateHTMLPage for obvious reasons and it takes 2 parameters: getURL, the page to get the contents of, and postFile, the HTML file that it will output the results to.

In Part 2 we will look at writing the output of the ASP page to an HTML file. This section concludes with the part of the CreateHTMLPage subroutine that uses ASPTear to obtain the output of the ASP page...

  • Read Part 2


    Sub CreateHTMLPage(getURL,postFile)
      '###################################################
      '#   change the variables below to match your site #
      '###################################################
    
      'replace "getSite" variable to the address of your site
      'to get the complete URL of the active file you want to run
      Dim getPage
      getPage = "http://www.yoursite.com" & getURL
    	
      'replace "postSite" to the physical address of your site
      'to make a composite physical address of the "HTML" file
      'you want to write to
      Dim postPage
      postPage = "C:\Inetpub\wwwroot\mysite" & postFile
    	
      '##################################################
      '#   end changes                                  #
      '##################################################
    	
      'variables for "ASPTear" component
      Const Request_POST = 1
      Const Request_GET = 2
    	
      'initiate component "ASPTear.dll"
      Dim TearObj
      Set TearObj = CreateObject("SOFTWING.ASPTear")
      Response.ContentType = "text/html"
     
      'Note on above line: you can actually skip it if your asp file
      'that you are calling has a similar declaration in its HEAD part,
      'like:
      '<meta http-equiv="Content-Type"
                content="text/html;
                charset=iso-8859-1">
        
      ' to collect the output of the ASP page as a string
      Dim strRetrieval
      strRetrieval = TearObj.Retrieve(getPage, Request_GET, _
                                      "", "", "")
    	
      'in case of error getting the page, output error
      'this is a direct copy from the documentation of ASPTear
      If Err.Number <> 0 Then
        Response.Write "<b>
        If Err.Number >= 400 Then
          Response.Write "Server returned error: " & Err.Number
        Else
          Response.Write "Component/WinInet error: " & Err.Description
        End If
    
        Response.Write "<b>
        Response.End
      End If
    
      Set TearObj = Nothing
    


    Windows Internet Technology | ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article



  • JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

    Solutions
    Whitepapers and eBooks
    Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
    Avaya Article: How to Feed Data into the Avaya Event Processor
    Microsoft Article: Install What You Need with Win Server ‘08
    HP eBook: Putting the Green into IT
    Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
    Avaya Article: Setting Up a SIP A/S Development Environment
    IBM Article: How Cool Is Your Data Center?
    Microsoft Article: Managing Virtual Machines with Microsoft System Center
    HP eBook: Storage Networking , Part 1
    Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
    MORE WHITEPAPERS, EBOOKS, AND ARTICLES
    Webcasts
    Intel Video: Are Multi-core Processors Here to Stay?
    On-Demand Webcast: Five Virtualization Trends to Watch
    HP Video: Page Cost Calculator
    Intel Video: APIs for Parallel Programming
    HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
    Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
    MORE WEBCASTS, PODCASTS, AND VIDEOS
    Downloads and eKits
    Sun Download: Solaris 8 Migration Assistant
    Sybase Download: SQL Anywhere Developer Edition
    Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
    Red Gate Download: SQL Compare Pro 6
    Iron Speed Designer Application Generator
    MORE DOWNLOADS, EKITS, AND FREE TRIALS
    Tutorials and Demos
    How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
    eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
    IBM Article: Collaborating in the High-Performance Workplace
    HP Demo: StorageWorks EVA4400
    Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
    Microsoft How-to Article: Get Going with Silverlight and Windows Live
    MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES