Click to return to the Essentials home page    
Web Workshop  |  Essentials

Autumnal Husbandry: Reusing Script Files, Automatic File Lists, and Other Thrifts


Jeff Brown
Rafael M. Muñoz
Microsoft Corporation

October 6, 1997
Updated: October 20, 1997

The following article was originally published in the Site Builder Magazine (now known as MSDN Online Voices) "Web Men Talking" column.

Contents
Spilling the contents - Browsing directory contents on Web servers
Your time is valuable - Reusable script files
Formalities - Developing documents for ASP projects
Hot off the press - Publishing documents on the Web
Menu malfeasance - Using pop-up menus in Java

The frost is on the pumpkin here in the Pacific Northwest, and the Web Men have reaped yet another heady harvest of questions. This time, they dig into document-publishing issues, ASP project documentation, the pros and perils of automatic file lists, script file reuse, and using Java to develop pop-up menus. Ready?

Spilling the contents

Dear Web Men:

I'm developing an intranet and am looking for a utility, or app, or script, or anything that will automatically read the contents of a directory (and subdirectories when the parent directory is clicked on) and spit back HTML stating the contents. I've seen lots that require you to "hard code" the directory structure into them, which kinda defeats the purpose. It's got to be built into an HTML page and rerun each time the page is accessed. This way the user sees the latest hypertext links to the directory contents. I've seen this done with a Java app, but it was very expensive to purchase.

Any other ideas? I'm running Internet Information Server 3.0 on a Windows NT® 4.0 box with Internet Explorer 4.0 as the browser of choice. Any help would be appreciated.

Vaughn Fox

The Web Men reply:

Vaughn, one way to accomplish this is to enable directory browsing on the Web server. Since you are using Internet Information Server (IIS) non-MSDN Online link, you can do this in the Internet Service Manager application.

When a specified directory contains no default document, IIS will return an HTML page listing all files in the directory, where each filename in the list is also a link. (The default document name is whatever you have set in IIS; by default, it is default.htm.) To see the file list, you need to enter the URL without specifying a document name, such as http://example.microsoft.com/directory/.

You can enable directory browsing -- and ensure that the directories you want to allow people to browse do not have default documents. Because the server builds the page whenever you request the URL for the directory, the file list will automatically reflect the current contents of the directory (how thoughtful!).

This sounds easy enough, but remember to take a step back and think about security. If there is a chance that some files you don’t want people to see might end up in the list of files, then directory browsing may not be a good idea. For more information on enabling directory browsing, refer to Chapter 6 of the IIS documentation, Planning Your Content Directories and Virtual Servers.

If you don’t want to enable directory browsing, or you want more control over how files are listed, you can try out a beta version of the Document Summary Information Active Server Pages (ASP) component (quite the mouthful, eh?).

This component searches for a designated file specification, and then creates an HTML page listing files that meet the specification. The listing includes the Summary Information property set associated with OLE Structured Storage files, such as Microsoft Excel or Microsoft Word files. If you specify files that do not have summary information, it will still list the creation and last-modification dates for the file, and the file name will be a link. To set the file specifications for the files you want to list, use the SetFileSpec method.

Back to topBack to top

Your time is valuable

Dear Web Men:

I did a JavaScript, and I included it into some HTML documents. Later I had to change this JavaScript, but I realized that I should change all my HTML documents. I decided to separate this JavaScript from my HTML documents for easier maintenance.

Using Netscape Navigator 3.0, I found that I can use this code:

<SCRIPT LANGUAGE="JavaScript" SRC="MyJavaScript.jv">
</SCRIPT>
But it didn't work with Internet Explorer.

I need to find an option for Internet Explorer. Please help me.

Filiberto Arceo

The Web Men reply:

Filiberto, like you, we hate wasting our time hunting down HTML pages to fix all our scripts -- and anyone who has done it once probably feels the same way. Why, our motto is "Live life to the fullest, you'll never look back and wish you had spent more time in the office." Reusable script files help with this mission.

First, to answer your question: Yes, Microsoft Internet Explorer  Non-MSDN Online link does provide a way to use script files. As you mentioned, Netscape Navigator uses the SCRIPT tag and the SRC attribute to include a script file. Internet Explorer uses the same thing; the difference comes in the choice of file extensions. Above, you show a file with the .JV extension. This works for Navigator, but for Internet Explorer 3.0 you must use a .JS file extension.

Your code for Internet Explorer would look like this:

<SCRIPT LANGUAGE="JavaScript" SRC="MyJavaScript.js">

From our previous columns, you can find information on how to detect browsers with the use of Active Server Pages (ASP) technology. Using ASP, you can give the file with each extension and let the browser-detection functionality choose the appropriate one for the surfing community. Note that we are talking about versions 3.x and earlier for Netscape and Internet Explorer. Internet Explorer 4.0  Non-MSDN Online link and Netscape Communicator will work with either extension. See, there is hope as more and more cooperation begins to happen and the Web continues to grow!

Microsoft Internet Explorer 4.0  Non-MSDN Online link builds on the idea of reusable scripts with a new technology called scriptlets, which are reusable, cross-platform Web components built as HTML pages. For the most up-to-date information on this new technology, check out the Scripting Technologies Web site.

Back to topBack to top

Formalities

Dear Web Men:

We are developing some Web applications using Active Server Pages and Internet Information Server, and we are having some difficulty documenting the design. We thought you might have some suggestions.

Normally, we create "traditional" software development documents, such as requirements, functional specification, design specification, test plan, etc. Our company is also ISO9000 certified, and we therefore use a controlled set of templates and processes to produce these documents.

We are finding that documenting Web applications that use ASP and IIS doesn't match well with our existing processes. For example, our existing documents include sections on each component developed for an application, the interface exposed to other applications or components, internal data structures, etc; and much of this is not relevant for a pure ASP application. I have searched the Microsoft MSDN Online site and several other Microsoft sites looking for samples or hints for writing design documents for ASP, but haven't found anything.

Do you have any suggestions, or have you published any articles on writing design specifications for ASP applications?

Philip Dickerson

The Web Men reply:

We can relate to formal documents and processes. Both of us have developed formal software documents, and in former lives worked for defense contractors. (Sorry if this displeases any of our readers who are anarchists.)

We did some hunting ourselves, Philip, and did not find much information on this. But when you think about it, there are more similarities than differences between ASP development and "traditional" software development. ASP applications have components and source files, global and local variables, global and local functions, inputs and outputs from components and functions, and so forth. You could consider an ASP page or group of pages to be a module or component, and it contains functions.

There are also components in the form of ActiveX™ server components, if you are using them. But the way that modules and components interface with each other is different than in "traditional" software. In other words, you call a function in another module indirectly through a URL. To call a function in an ActiveX server component, you create an instance of it in an ASP page, and then call its methods, set its properties, and such.

The key is probably just coming up with a "traditional" object-oriented or functional design, and then looking at how it can be expressed in the elements that ASP has available. Then stay away from things you don't need. For example, even though ASP allows you to intersperse script and HTML, which is kind of cool, a cleaner and more maintainable way of doing output would probably be to do it in a function with Response.Write().

Hopefully, this has shed some light on things. If we find some more useful information on this topic, we will include it in a future column.

The upcoming Resource Kit for Microsoft IIS 4.0 non-MSDN Online link will have some information on standards planning when developing ASP/IIS applications. It will also include some useful testing tools, so you may want to take a look at it when it becomes available.

Check back for articles in the Server area of the Site Builder Workshop. In particular, the articles about improving style and performance in ASP applications about troubleshooting techniques should be useful.

Also, take a look at other Active Server resources listed on the SBN Technology Sites page, which has links to some great resources for building ASP/IIS applications.

Back to topBack to top

Hot off the press

Dear Web Men:

I am beginning my adventures into this "Web Thang" phenomenon for my company in an attempt to show the value, cost savings, etc. I would like to take Excel spreadsheets that are currently e-mailed around the company universe and easily make them Web displayable without plug-ins or doing the manual process of "Save As HTML."

Any utilities or automated processes/objects/ActiveX stuff that would streamline this process? FYI: I am not currently an ActiveX knowledge user.

Tom Foulke

The Web Men reply:

Tom, buckle up for what will definitely be a wild ride on that "Web Thang." For your publishing needs today, we'll share a solution that will enable you to update your files immediately by replacing them on your server -- without having to process them manually into HTML files.

Use the Internet Server Application Programming Interface (ISAPI), which is an alternative to using Common Gateway Interface (CGI) executable files. ISAPI extends the functionality of ISAPI-compliant Web servers, such as IIS  Non-MSDN Online link. You need to create an ISAPI filter that converts files for "automatic file publishing."

The wonderful folks at the MSDN Online Web Workshop have already done the legwork for you in the article Building ISAPI Filters and the CVTDOC Sample. CVTDOC is an ISAPI filter that provides sample programs that dynamically convert Microsoft Word documents, Microsoft Excel worksheets, and text files to HTML for publishing on the Web. This article completely describes how the filter was created, and how to use it. Understanding this filter is the key to creating conversion programs for other document types.

Back to topBack to top

Menu malfeasance

Dear Web Men:

I've searched high and low for an answer, and you're my last resort, so I hope you can help. I've been using Visual J++ 1.1, and wanted to create pop-up menus. Since the AWT that originally shipped with Visual J++ doesn't have the PopupMenu class, I installed the beta version of the SDK 2.0. I managed to get everything running, and the pop-ups worked just great, until I tried using Netscape 3.0 and Internet Explorer 3.0 to test the applets. Both browsers refused to recognize the pop-up class (naturally!). So I've had to give up the idea of using pop-up menus for the time being. Anyway, my question is: How do I create pop-up menus in Java, without using the built-in class? Or alternatively, is there a way to make the existing applet (which uses the SDK 2.0) work on browsers that don't recognize the PopupMenu class as yet? Thanks a lot.

Priya

The Web Men reply:

Since you searched high and low, you must have found us somewhere in the middle. And we do have some suggestions to get pop-up menus to behave themselves on all Java-enabled browsers.

To sum things up, the PopupMenu class for AWT (the UI library for Java) is a Java Development Kit (JDK) 1.1 feature, and Microsoft Visual J++ 1.1 Non-MSDN Online link shipped before the JDK 1.1 was available. To be precise, the AWT package is provided by the Java Virtual Machine (VM). In addition to the Visual J++ development tools, the Visual J++ setup program installs Internet Explorer and the Microsoft Win32 Virtual Machine for Java (Microsoft VM). A new version of the Microsoft VM does support the PopupMenu class and other JDK 1.1 features. This new Microsoft VM is, as reader Priya pointed out, included in the Microsoft SDK for Java 2.0 Non-MSDN Online link. It also is included in Internet Explorer 4.0 Non-MSDN Online link.

Rather than writing all the code for a PopupMenu class yourself, searching the Web for one, or waiting for other browsers to catch up and support JDK 1.1, we recommend using Microsoft Application Foundation Classes (AFC) Non-MSDN Online link.

You can use the UI package of AFC to create menus, including pop-up menus, that have text, images, or even other controls as menu items. In contrast, the PopupMenu class of AWT is rather primitive, because menu items are limited to text.

AFC includes a variety of classes to build very usable and sharp-looking GUIs for Java applets and stand-alone applications. The AFC packages are written in Java, too -- and will run on browsers (Java VMs) that support the older JDK 1.02 AWT classes and event model, as well as the new JDK 1.1 classes and event model. You can find out more about AFC and download it from the Microsoft Technologies for Java site Non-MSDN Online link.

Back to topBack to top

Jeff Brown, when not forcing family and friends to listen to Zydeco and country blues music, helps develop Microsoft Mastering Series titles -- with a smile.

Rafael M. Munoz is a part-time Adonis, and full-time support engineer for Microsoft Technical Support. He takes it very, very personally every time you flame Microsoft.


The Web Men in Short

Added October 20, 1997

Q: Gordon Price wonders how he can prompt users to download fonts on his intranet site.

A: See our archived Express yourself answer about font embedding.

Q: Arun Shroff wants to know what happened to the Microsoft Internet Control Pack.

A: Information, download, and support of the Internet Control Pack have been transferred to NetMasters LLC. Please visit their Web site Non-MS link.

Q: Lyle Boomer asks how to link data to a marquee control and edit only the text for the marquee.

A: Use the MARQUEE tag instead, and data binding. The text can be in a separate file, and can be plain text or HTML. See a working example in Binding HTML Elements to Data.

Posted October 6, 1997

Q: Kevin asks how to create redirect pages when moving Web pages around a Web site.

A: The first solution is through the use of a meta tag: <META HTTP-EQUIV="REFRESH" CONTENT="0; URL=/URL/page.htm">. Another solution is to search on Yahoo!  Non-MS link for "redirect page" for companies that provide free redirect services.

Q: Duane Gayer will use Internet Explorer 4.0 and FrontPage 98. How can he create online databases?

A: Check out the Database Region Wizard in FrontPage 98 Non-MSDN Online link. See Mary Haggard’s Dreaming of Databases column for a summary of database technologies.

Q: John Autry wants to link an anchor to a page that is part of a frame set, and view it without the other frames.

A: Just include the name of the page that is being used in the frame set. View the source to obtain the names of pages used in the frame set. You can also right-click on the frame you want to use, and select "View Source" on Internet Explorer  Non-MSDN Online link or "View Frame Source" on Netscape Communicator to get the page title.

Q: Justin Young asks if embedded frames can be created in Web pages.

A: Yes, use the IFRAME tag to create a floating frame. Refer to the HTML Elements Reference.

The Web Men's Greatest Hits

List of Web Men Topics

Write us!



Back to topBack to top

Did you find this article useful? Gripes? Compliments? Suggestions for other articles? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.