Intranet Journal   Earthweb  
Images Events Jobs Premium Services Media Kit Network Map E-mail Offers Vendor Solutions Webcasts

   Intranet Journal Subjects
Search Earthweb

Privacy Policy



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

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

internet commerce
Be a Commerce Partner
















 

[ Home | Discussion Forum | How Do I... | Lotus Notes Intranets | Microsoft SharePoint | Products | Shopping  ]

free news!


Simple ASP Chat


By Sanjay Shetty

Creating the Main Form
To start with create a simple form where the user can type some text. Whatever the client types in this form has to be appended to a text file, this text file will then be displayed to the client. The actual writing to the text file is done with an Active Server Script.
 	<FORM method="post" action="chat.asp">
<Input type=text value="" size="35" name="txtbox">
<Input type=submit value="GO">
Refreshing the Page
By including the meta tag for refreshing the page will be refreshed every 5 seconds. This concept is called client pull. This is because it is the clients responsiblity to read the meta tag and call for a refresh every five seconds.
<HEAD>
<META http-equiv="refresh" content="5">
</HEAD>

The form for submitting the data and the page for reading the text are on two different pages. In order to combine them we put both pages with in a frame. This allows the user to easy type and read the responses without being interrupted.

Installation is fairly simple, just follow these steps:
  1. Create a virtual root called "asp", make it giving it Execute Access
  2. Download and expand ftp://ftp.15Seconds.com/012497.zip (1064 bytes) into the virtual directory just created.
  3. Create a blank text file in that directory called textwork.txt

If you want to change the name of virtual root, you must change the name in the Active Server Page code since it uses the virtual root name to find the text file's path.

Mainchat.asp could be mainchat.htm, and located in a directory with read access but the installation is easier with all the files in the same directory.

The Active Server Page
Since the above form is in a file called chat.asp and the form posts to chat.asp, the form post to itself. To handle the output of the post you need some Active Server Code.

<%

textstr=Request.Form("txtbox")
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
TestFile = Server.MapPath ("/asp") & "\textwork.txt"
Set OutStream= FileObject.OpenTextFile (TestFile, 8, TRUE)
ipaddr=Request.ServerVariables("REMOTE_ADDR") & " : "
OutStream.Write ipaddr
OutStream.WriteLine textstr & "<BR>"
Set OutStream = Nothing
%>

Active Server Page
<%
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
TestFile = Server.MapPath ("/asp") & "\textwork.txt"
Set InStream= FileObject.OpenTextFile (TestFile, 1, False, False)
Response.Write Instream.ReadALL & "<BR>"
Set Instream=Nothing
%>

Here a Fileobject is created in the READ mode by specifying the parameter 1 to the OpenTextFile() method. In the following statement two things are done in one stroke. The READALL() function is used to read the entire contents of the file and then the Response.Write function is used to output the entire file to the client. The final step it to close the object.

Simple ASP Chat
This issue focuses on the use of Active Server Pages to dynamically create a chat page. The converstaion is stored in a file object. The chat pages are contained with in a framed page broken into two sections. The upper frame is the main view of the converstaion. The lower frame allows the viewer to input a line to the conversation. The upper frame refreshes based on a Meta refresh tag, each time reading the file and displaying it's contents. The lower frame writes a line of converstaion to the file.
Explaination
The first line of code uses the IIS provided Request object to find the value present in the txtbox that is filed in the form.
textstr=Request.Form("txtbox")< /FONT>
The value is stored in the textstr variable.

Next the Fileobject is opened it's reference is stored in the Fileobject variable.

Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
TestFile = Server.MapPath ("/asp") & "\textwork.txt"
Then we specify the file name and it's path and store it in a variable called Testfile. Here we have a file called textwork.txt to which all the text of the chat is appended.

Next step is to open this file in append mode by specifying the number 8 to the OpenTextFile method.

Set OutStream= FileObject.OpenTextFile (TestFile, 8, TRUE)
ipaddr=Request.ServerVariables("REMOTE_ADDR") & " : "
The other thing that is being done in this section is storing the ip address of the client to a variable and appending the string " :" to it.

OutStream.Write ipaddr
Writes the IP address of the client to the file.

OutStream.WriteLine textstr & "<BR>"
Writes the text written by the client and appends the BR tag. This tag is added so that when we display the chat session to the clients with each text row on a new line.

Once having done that the stream is closed that is opened to the file.

Set OutStream = Nothing< /FONT >


Next: Creating Excel WorkSheets with ASP

Index: Active Server Pages\IIS

About the Author
Sanjay Shetty, was doing Computer Eng.. but dropped out of a college. Got involved in the HARE KRISHNA culture meanwhile started Nirvana Software Consultancy in 1994 a firm which specializes in database application software development using FoxPro on the Windows platform. In 1996 started another company, DBS Internet Services along with a couple of other friends and colleagues. The company specializes in creating and hosting internet/intranet web sites and also specializes in developing internet/intranet applications.

   
Of Interest
Tools of the Trade








 Intranet News 
* Intranet/Internet Product Summary: January 04, 2001
* Red Herring Picks Plumtree for Employee Portal
* Tideworks Goes with Intranet from Eprise
* Crayfish Nabs 47 Percent of Intranets.com's Japan Arm
* IntraNet Solutions Notches Belt with Oakwood
* BT Secures Corporate Portal Help from Plumtree
* Mobilize Offers Enterprise App to Lexis-Nexis

More News

In' tra net - n. 1) a computer network connecting an affiliated set of clients using standard internet protocols, esp. TCP/IP and HTTP. 2) an IP-based network of nodes behind a firewall, or behind several firewalls connected by secure, possibly virtual, networks.
  IDM Unwired  
IDM on the Road
NOW AN OFFICIAL AVANTGO CHANNEL!
To easily add IDM to your PDA
click here

Featured Archive Articles

  •  Putting Your Intranet to Work: 50 Ideas for Department-Specific Applications
  •   Five-steps to implement your intranet and manage your strategic information
  •  A new generation of intranet tools intersects Customer Relationship Management and Sales Force Automation
  •   Business Intelligence and the Intranet
  •  Effective Intranet Publishing: Getting Critical Knowledge to Any Employee, Anywhere


  •   Using an Intranet to Manage 610,000 animal specimens with Java
  •  Putting JavaScript to Work for Your Intranet
  •   JavaScript Forms and Frames
  •  Introduction to the Browser Object Model
  •  Black Hole Sun: Java is Going Supernova Thanks to its Creator's Gravitational Pull


  •   Managing Large Collections of Documents: A full-length excerpt from the book "Intranet Document Management."
  •  Intranet Traffic Management: Without Quality of Service standards, intranets and extranets face death by success
  •  Issues in Intranet Security: A primer on keeping the keys to the enterprise safe


  •   Report from the trenches: Firms weigh in on intranet deployment trends
  •  The Magna Carta of the Intranet: From Smart Companies, Smart Tools
  •   Prudential HealthCare Launches Extranet to Manage Health Benefits
  •   Wells Fargo Unit Looks To Establish Its Intranet as a 'Portal'
  •   Amkor/Anam's intranet is a study in open systems integration


  •  Tutorial: Finding Your Way Around E-commerce
  •   The Essential Supply Chain
  •  A Definition of Data Warehousing
  •   Internet Messaging: from the Desktop to the Enterprise


  •  Improving Intranet Information Retrieval with Human Indexing
  •   An XML Development Kit
  •   When To Use Active Server Pages
  •  Intranets and extranets for virtual project management
  •  Why Groupware is Hard
  •  Optimizing Web Pages For Handheld Devices


  •  Version Control within a Collaborative Extranet
  •   Electronic Procurement, Extranets and You
  •  Intranet and extranets for virtual project management
  •  Overview of Virtual Private Networks


  •  What's the Future of Application Service Vendors?
  •  'Enterprise Portal' - a New Catch Phrase, But Definitions Vary
  •   Portals, You Say? This One's Private Ericsson's intranet is a give-and-take affair with employees
  •  Application Hosting

Elsewhere on internet.com
*  What Happened at XML 2000?
*  Collaborative Computing: This Changes Everything
*  inFusion: Bringing ColdFusion to a Mail Server Near Youn
*  Netscape 6, Part I: Detection and Scripting
*  AOL Introduces Mobile Communicator
*  NetMenu2
*  Bluetooth Security
*  DHTML Hiermenus 4.0: The Page-Specific Parameters
*  XML Content Syndication: Part 2
*  HardwareCentral Update: Intel's Pentium 4, a New Architecture Unveiled



Copyright 2002 Jupitermedia Corporation, All Rights Reserved.
Legal Notices | Licensing, Reprints, & Permissions | Privacy Policy | Advertising on Intranet Journal
Home | eXchange | F A Q | Find | Register |