Novell is now a part of Micro Focus

More Dynamic Web Pages With IntranetWare

Articles and Tips:

Terry L. Jeffress

01 Jun 1997

Editor's Note: This article is the second part of a two-part seriesthat explains how to use IntranetWare to publish dynamic HyperText MarkupLanguage (HTML) documents. The first article, which appeared in the Mayissue ofNetWare Connection,explained how to use Server Side Include(SSI) commands and NetBasic scripts to create dynamic elements in HTML documents.(See "Dynamic Web PagesWith IntranetWare,"pp. 6[shy ]20.)

After you master HTML, you can use the Novell Web Server 3.1 componentof IntranetWare to create dynamic documents. When a user requests a dynamicdocument, Novell Web Server 3.1 or the user's World-Wide Web (WWW) browsergenerates the entire document or a portion of the document, depending onhow the document is created. Using dynamic documents, you can customizeinformation for Internet or intranet users.

IntranetWare includes several tools for creating dynamic documents. Ifyou know how to write computer programs, you will find Perl scripts, JavaScriptscripts, and Java applets especially useful. Because using these tools requiressome programming experience, this article provides only an overview of eachtool's capabilities. However, this article also includes a list of resourcesthat will help you learn how to use these tools effectively. (See Additional Resources for Learning Perl, JavaScript,and Java.")


Perl was developed as a UNIX management tool to read text files and printreports based on these files. Perl does more than just process text, however:Perl is a sophisticated, general-purpose programming language that offersmath functions, file system functions, and objects. Perl scripts for IntranetWareare programs written using Perl 5, the latest version of the Perl scriptinglanguage.

Like NetBasic scripts, Perl scripts can generate entire HTML documents.However, Perl scripts can also send files other than HTML files, such asimages called from an HTML>IMG>tag.

Perl, like NetBasic, is an interpreted language. As a result, the IntranetWareserver uses a Perl interpreter, which runs as a NetWare Loadable Module(NLM), to process Perl scripts. When you install the Novell Web Server 3.1component of IntranetWare, the PERL5 NLM is installed in the SYS:INW_WEB\SHARED\LCGI\PERL5directory.

Because the Perl interpreter for IntranetWare runs as a Common GatewayInterface (CGI) application, you cannot run Perl scripts from the IntranetWareserver console. Novell Web Server 3.1 loads the Perl interpreter only whena user requests a Perl script. (For information about CGI applications,see the "CGI Solutions for Novell Web Server 3.0" section in DynamicWeb Pages With IntranetWare," NetWare Connection, May 1997,p. 20.)

Unlike NetBasic, which can interact with the IntranetWare operating system,the file system, and the Novell Directory Services (NDS) database, Perlcan access only the IntranetWare file system. Because Perl's strength liesin its ability to manipulate data, Perl is often more powerful than NetBasicfor working with files.

In addition, large archives of public Perl scripts are available. Insteadof writing new Perl scripts, you can modify these public scripts to meetthe needs of your company. (For more information about Perl, see "Additional Resources for Learning Perl, JavaScript,and Java.")

As a security measure, Novell Web Server 3.1 can access only Perl scriptsthat are stored in the SYS:\INW_WEB\SHARED\DOCS\LCGI\PERL5 directory. Ifyou want to use Perl scripts, you must ensure that the scripts are storedin this directory.

You can assign Perl scripts any valid filename. By convention, however,you should use the .PL extension for Perl scripts, although this extensionis not required.

Understanding the Perl Script Environment

Before you begin writing Perl scripts, you should understand how a user'sbrowser requests a Perl script and how Novell Web Server 3.1 calls and processesthat Perl script. Novell Web Server 3.1 calls and processes a Perl scriptin much the same way that it calls and processes a NetBasic script, withone major exception: Novell Web Server 3.1 sends a request for a NetBasicscript to the CGI2NMX NLM, which then converts the request into NetWareModule eXtension (NMX) commands that the NetBasic interpreter can understand.In contrast, the PERL5 NLM is a CGI application, which means that NovellWeb Server 3.1 can communicate directly with the PERL5 NLM; no intermediateNLM is required.

Like NetBasic scripts, Perl scripts run only when a user requests them.To request a Perl script, a user types the request directly into a browseror clicks on a hypertext link that requests the Perl script. In either case,the user's browser requests a uniform resource locator (URL) similar tothe following:

In the server resources map (SRM.CFG) for Novell Web Server 3.1, each virtual WWW server is configured to pass any requests that include /perl/after the site name to the PERL5 NLM. (For more information about virtualWWW servers and configuring Novell Web Server 3.1, see "Electronic Publishing With IntranetWare: Just Another Branch on Your NDS Tree," NetWare Connection, Mar. 1997, pp. 6[shy ]18. If the PERL5 NLM is not loaded, Novell Web Server 3.1 loads this NLM and then passes the Perlscript request to the NLM. The Perl interpreter then executes the Perl script,sending the resulting HTML document back to Novell Web Server 3.1, which,in turn, passes this document to the user who requested it. (See Figure 1.)

Figure 1: When a user's browser requests a Perl script, Novell Web Server 3.1 passes this request to the PERL5 NLM, which runs the requested script and returns the result.

Creating Dynamic Documents With Perl Scripts

Perl scripts are ASCII text files that you can create using any texteditor or word-processing application. After you create a Perl script, youmust place it in the SYS:\INW_WEB\SHARED\DOCS\LCGI\PERL5 directory.

The code below shows a small Perl script and theHTML document this script generates. Line 1 tells the Perl interpreter touse the Perl script library for Novell Web Server 3.1. You can use the routinesincluded in this library to manipulate CGI input and to format output.



  1  require(""); 

  2  print &PrintHeader;
  3  print "<HTML>\n"; 
  4  print "<HEAD><TITLE>A Perl Script</TITLE></HEAD>\n";
  5  print "<BODY>\n";
  6  print "Hello, Web clients!\n"; 

  7  print "</BODY></HTML>\n";




 <HEAD><TITLE>A Perl Script</TITLE></HEAD>
 Hello, Web clients!


Note: Line numbers displayed next to the Perl script are not part of the script itself.

Line 2 calls the PrintHeader subroutine from the Perl script library.The PrintHeader subroutine sends a message to Novell Web Server 3.1, indicatingthat the Perl script will be sending an HTML document.

Lines 3 through 7 demonstrate the Perl print command. When writing aPerl script to create a dynamic document, you use this command to returndata to Novell Web Server 3.1, which, in turn, returns the data to the user'sbrowser. You must also include all of the HTML tags you want in your dynamicdocument in a Perl print command.

You can use many other Perl commands to manipulate data and to controlprogram flow through conditional statements (such as"if-then"statements). For example, you could create a Perl script that interpretsdata from an online form and creates a new HTML document based on that data.(For more information about Perl commands, see "AdditionalResources for Learning Perl, JavaScript, and Java.")

Creating Links to Perl Scripts

After you have written a Perl script, you must create a way for usersto request this script and view the resulting HTML document. The easiestway to provide access to a Perl script is to create a hypertext link inan HTML document such as your WWW home page. To create such a link in astatic document, you would add a line similar to the following:

<a href="/perl/">Launch Perl Script</a>

If a user viewed a static document containing this line, he or she wouldsee"Launch Perl Script"as a hypertext link. When the user clickedon the link, Novell Web Server 3.1 would instruct the Perl interpreter torun the Perl script. The user would then see the dynamic document generatedby

Of course, there are other ways to create links to a Perl script: Youcan write a NetBasic script or a Perl script that creates an HTML document,which contains a hypertext link to a Perl script. This Perl script, in turn,generates a dynamic document. For example, suppose that you included thefollowing HTML line in a Perl print command:

<a href="/perl/">Launch Perl Script</a>

In this way, you would create a link to within another Perlscript.


Like NetBasic and Perl, JavaScript is an interpreted programming language.However, JavaScript scripts have little else in common with NetBasic scriptsand Perl scripts.

Both NetBasic and Perl scripts are server-side processes. That is, theserver must perform extra work to produce the dynamic elements in the HTMLdocument. In contrast, JavaScript scripts are client-side processes, whichare processed by a user's browser. As a result, Netscape Navigator 2.0 orhigher and Microsoft Internet Explorer 3.0 or higher include a JavaScriptinterpreter.

Unlike NetBasic and Perl scripts, JavaScript scripts can be includedas executable code directly in an HTML document. To use a JavaScript scriptin this way, you include the HTML>SCRIPT>and>/SCRIPT>tagsin the HTML document. You can also write JavaScript scripts as separatedocuments that are called from within an HTML document.

Placing JavaScripts in HTML Documents

You can place JavaScript scripts almost anywhere in an HTML document.For example, if you wanted a user's browser to interpret a JavaScript scriptwhile displaying an HTML document, you would include the script at the placein the document where the script's output should appear.

To embed a JavaScript script in an HTML document, you would use the HTML>SCRIPT>tag to indicate that a JavaScript script follows, and youwould use the>/SCRIPT>tag to mark the end of the script. For example,in the code below, the HTML document includes an embeddedJavaScript script, which generates the text shown in the browser window.

 <TITLE>Powers of Two</TITLE></HEAD>
 <H2>Powers of Two</H2>
 document.write("2^0 = 1<br>")
 for(i = 1, fact=2; i > 17; i++, fact *= 2) {
    document.write("2^" + i + " = " + fact);



The JavaScript script in Figure 3 uses theJavaScript document.write() method to send output from the script to a user'sbrowser. (Amethodis an object-oriented programming term for a functionor procedure.) The document.write() method sends the parameters you placein parentheses to the user's browser as HTML text.

As a result, the document.write() method is not limited to printing data.This method can also print HTML tags that a user's browser parses, or interprets.The browser then displays the results for the user.

JavaScript includes many other methods that enable you to display text,control a user's browser, interact with forms, and process events, suchas a user clicking a button. For example, you can embed JavaScript commandsas parameters within other HTML tags. The HTML document in the code below illustrates how you can configure a JavaScript script to run whena particular event occurs, such as a user moving the mouse pointer overa hypertext link.

 <HEAD><TITLE> Example of Event Handlers</TITLE>
 <H3>Example of onMouseOver and onMouseOut Event Handlers</H3>
 <A HREF="" onMouseOver="window.status='A message: Hello!' ; return 
    true;" onMouseOut="window.status=' ' ; return true;">
 Point to this text</A> and look at the status bar.

Suppose that you created the HTML document in the code above. If a user accessed this HTML document and moved the mouse pointerover the text"Point to this text,"the user's browser would runthe JavaScript commands contained in the onMouseOver parameter. As a result,the wordsA message: Hello!would appear in the browser's statusbar at the bottom of the browser window. When the user moved the mouse pointeroff the hypertext link, the browser would run the JavaScript command thatwould erase the message displayed in the status bar.

In this example, the JavaScript commands are part of the parameter'sarguments. However, you could also use the onMouseOver parameter to runa JavaScript script that was defined in another place in the HTML document.

What JavaScript Can Do

Because JavaScript is a relatively general-purpose programming language,you can write JavaScript scripts to perform abstract computations, suchas finding prime numbers or calculating trigonometric functions. However,abstract computations are not usually very interesting, even when viewedwith a browser. The real power of JavaScript is its ability to manipulatebrowser objects. For example, you can use JavaScript scripts to performthe following types of functions:

  • Control the Appearance and Content of Documents. In addition to using JavaScript scripts to display static text in a browser window, you can use JavaScript scripts to write dynamic variables, such as the current date or the date the current HTML document was last modified, to the browser window. You can also use JavaScript scripts to set and change the colors for the HTML document's background, text, and hypertext links.

  • Control the Browser. You have already seen that you can change the contents of the browser's status bar. You can also use JavaScript scripts to create dialog boxes that display messages or prompt the user to enter information.

  • Interact with HTML Document Content. You can read from and write to any element in an HTML form. For example, you could create a WWW-based expense form. When a user entered values in this form, JavaScript scripts could perform calculations and enter values in other fields within the form.

  • Perform Functions When a Particular Event Occurs. You can write JavaScript scripts that run when an event occurs. For example, if a user clicked a button in an HTML form or pointed to a hypertext link or image, a particular JavaScript script would run.

  • Read and Write Cookies. Cookiesare small amounts of data that a browser stores on a user's workstation. Each cookie is associated with a particular URL. When a user accesses a WWW page, the user's browser sends the associated cookie as part of its request for that page. For example, a cookie could store a user's login name and password so that the user would enter this information only the first time he or she opens an HTML document. On subsequent visits, the user would be logged in using the data stored in a cookie on the user's workstation. You can use JavaScript scripts to read the value of a cookie and to dynamically generate a portion of an HTML document or an entire HTML document based on the value of the cookie.

  • Manipulate Images. JavaScript scripts can change an image that is displayed by an HTML>IMG>tag. With this feature, you can produce sophisticated effects. For example, you could make an image change when a user moves a mouse pointer over the image or when a user clicks on a particular button. (For an example of this feature, see the buttons on theNetWare ConnectionWWW site at For more information about JavaScript scripts, see "Additional Resources for Learning Perl, JavaScript, and Java.")

What JavaScript Cannot Do

JavaScript scripts can perform many functions, but they are limited tobrowser- and HTML-related tasks. Since JavaScript scripts have this limitedcontext, they cannot perform the following functions:

  • Draw Graphics. Because JavaScript scripts are limited to placing HTML codes and formatting the text displayed in HTML documents, you cannot use these scripts to draw graphics.

  • Read Files or Write to Files. For security reasons, JavaScript scripts cannot read files or write to files on the user's workstation (with the exception of cookies).

  • Perform Networking Functions. Although JavaScript scripts can instruct a browser to load a particular URL, they cannot perform any network functions.

  • Support Multithreading. JavaScript does not support multithreading, which is the ability to have two or more processes running independently and concurrently.


Java is an object-oriented programming language designed by Sun Microsystems.Originally, Java was designed as a platform-independent programming languagefor controlling consumer electronics. Because Java is platform independentand portable, it is the ideal language for developing applications for theInternet.

With Java, you can write small Java applications--calledapplets--thata Java-enabled browser can download from an Internet or intranet serverand run safely on any platform.

Java Is Not JavaScript

Other than sharing the nameJavaand some programming constructs(such as"if"statements,"while"loops, and booleanoperators), JavaScript and Java have virtually nothing in common. Whereas Java was developed by Sun Microsystemsas a portable, secure programming language, JavaScript was developed byNetscape Communications to add scripting capabilities to its browser andWWW applications. Even the shared name Java is a tenuous connection:Netscape originally called its scripting language LiveScript.

Despite their differences, JavaScript and Java work well together. InNetscape Navigator 3.0 or higher, JavaScript can communicate with the Javainterpreter built into the browser and can work with and control any Javaapplets on a WWW page. This feature, calledLiveConnect, enablesyou to use the strengths of both tools. For example, you could write a JavaScriptscript to control the browser's behavior (which Java cannot do), and youcould write a Java applet to draw graphics (which JavaScript cannot do).

Java Applets

Whereas SSI commands, NetBasic scripts, Perl scripts, and JavaScriptscripts are interpreted, Java applets are compiled. For example, when auser's browser executes a JavaScript script, the browser interprets theJavaScript commands in the HTML document and converts these commands intoinstructions the workstation's processor can perform. In contrast, beforeyou can execute a Java applet, you must compile the applet into Java bytecode, which can be executed by a Java Virtual Machine. (A Java Virtual Machineis a software implementation of a processor that runs Java byte code.)

The Java language syntax is similar to the syntax of the C programminglanguage, so C and C++ programmers can easily learn to use Java. Despitehaving similar syntax, however, the C programming language and Java arevery different: C, C++, and other compiled programming languages must compilea different application for each platform. Compiled Java applications andapplets, on the other hand, run on any implementation of the Java VirtualMachine. As a result, Java applets are completely portable and platformindependent.

In addition, C and C++ programs can access all of the resources on yourworkstation, such as your workstation's RAM and peripheral boards. Becauseall of your workstation's resources are accessible, a C program could includemalicious code such as a computer virus that would reformat your hard drive.In contrast, Java applets must run within the Java Virtual Machine, whichis a secure environment. As a result, a Java applet cannot crash your workstation,introduce viruses, or even write to your workstation's hard drive withoutfirst getting your permission. (For more information about Java and developingJava applets, see "Additional Resources forLearning Perl, JavaScript, and Java.")

Running Java Applets From an HTML Document

You place Java applets in HTML documents in much the same way that youinclude images. To include an image in an HTML document, you use the HTML>IMG>tag and specify in the SRC parameter the name of the file thata user's browser should download and display. To include a Java applet inan HTML document, you use the HTML>APPLET>tag and specify in theCODE parameter the name of the file that a user's browser should downloadand pass to the browser's Java Virtual Machine. The code below shows an HTML document that calls a Java applet.

 <TITLE>Load an Applet</TITLE>
 Below this text is a Java applet:<BR>
 <APPLET CODE="Applet.class" WIDTH=150 HEIGHT=100>

The<APPLET>tag is similar to the<IMG>tag in other ways.For example, you have the option of defining the height and width of thearea in which the Java applet will appear. However, the<APPLET>tag differs from the<IMG>tagin one important way: The opening<APPLET>tag requires a closing</APPLET>tag.

If a user's browser does not support Java applets, the browser will displayany text that you place between the opening and closing APPLET tags. Forexample, you could use the following lines to notify a user that his orher browser did not download and run an applet:

<APPLET CODE="Applet.class">

If your browser were capable of running applets, you'd see a Java applethere.

What Java Applets Can and Cannot Do

Because Java is a complete programming language, Java applets can doalmost anything. As mentioned earlier, you can use Java applets to drawgraphics or display text. Java also includes a complete toolkit of GUI objects.You can use objects such as menus, text fields, radio buttons, and checkboxes to display information and receive input from the user. Java appletscan also play sounds, open new windows, control the information in thesewindows, and interact with the network to download files. Java can eveninteract with CGI applications running on your server.

However, Java applets do have some limitations. For example, Java appletscannot perform the following functions:

  • Write Data to Workstation Drives Without Permission. Some browsers, such as Netscape Navigator, never allow Java applets to write data to the hard drive on a user's workstation--even if the Java applet has the necessary rights.

  • Read Data From Workstation Drives Without Permission. Netscape Navigator never allows Java applets to read data from the hard drive on a user's workstation.

  • Delete Files.

  • Read From or Write to Arbitrary Memory Addresses. Java applets cannot access memory outside of the Java Virtual Machine.

  • Introduce Computer Viruses.

The Java Virtual Machine enforces these limitations, which ensure thatJava applets provide a secure method of delivering applications over theInternet.


With IntranetWare, you can create dynamic documents that provide realvalue to your users. Through dynamic documents, users can access your company'sdatabases, read up-to-date company news, and access just about any informationthat you can store on an IntranetWare server.

Some IntranetWare tools, such as SSI commands, are relatively easy touse and can be implemented by anyone. If you require a more complex solution,however, you will probably want to don your programmer's cap and write Perlscripts, JavaScript scripts, or Java applets that make your users wonderhow they ever managed without your company's intranet or WWW site.

Terry L. Jeffress works for Niche Associates, which is based in SaltLake City.

NetWare Connection, June 1997, pp.16-25

Additional Resources for Learning Perl, JavaScript, and Java

If you want to use Perl scripts, JavaScript scripts, and Java applets to create dynamic HyperText Markup Language (HTML) documents, you may want to learn more about these programming tools. The following resources are a good place to start:

  • CGI Programming on the World Wide Web by Shishir Gundavaram (ISBN 1-56592-168-2). This book offers a comprehensive explanation of the Common Gateway Interface (CGI). Nearly all of the examples in the book are Perl scripts, so you can use most of these examples directly on your IntranetWare server. However, CGI Programming on the World Wide Web assumes that you are using CGI programs on a UNIX platform, so some of the examples will not work with IntranetWare.

    Gundavaram includes three chapters on processing online forms: He begins with processing simple forms, moves to more advanced forms, and then ends with passing information between multiple forms. Gundavaram also describes graphics, image maps, cookies, gateways to database applications, and Internet communications. For more information about this book, visit O'Reilly and Associates's World-Wide Web (WWW) site ( You can also call 1-800-998-9938 or 1-707-829-0515.

  • Programming Perl, 2nd edition, by Larry Wall, Tom Christiansen, and Randal L. Schwartz (ISBN 1-56592-149-6). Programming Perl is the authoritative work on using the Perl scripting language, which you would expect since Larry Wall, the inventor of Perl, is one of the authors. This second edition covers every aspect of using Perl 5. For example, chapter 2, "The Gory Details," clearly describes the syntax and semantics of Perl. Other chapters describe with equal clarity how to use functions, how to create data structures, and how to use Perl's object-oriented features. To quote a cliche: If you only buy one Perl book, this book should be the one. For more information about Programming Perl, visit O'Reilly and Associates's WWW site ( You can also call 1-800-998-9938 or 1-707-829-0515.

  • The Perl Language Home Page ( The Perl Language Home Page is maintained by Tom Christiansen, one of the authors of Programming Perl. On this WWW home page, you can find announcements about the latest revisions of Perl and links to online resources for learning about Perl.

  • The Comprehensive Perl Archive Network ( The Comprehensive Perl Archive Network (CPAN) contains hundreds of public-domain Perl utilities, Perl documentation, answers to Frequently Asked Questions (FAQs), and source code for various implementations of Perl. More than 60 WWW sites throughout the world mirror CPAN, so you should be able to find a site near you. For a list of sites, download the SITES.HTML file from any CPAN archive.

  • JavaScript: The Definitive Guide, 2nd edition, by David Flanagan (ISBN 1-56592-234-4). JavaScript: The Definitive Guide thoroughly describes the JavaScript language. Nearly every page includes sample code that illustrates each aspect of JavaScript. This book also includes a JavaScript reference section that consists of more than 250 pages. This section describes every JavaScript object, property, constant, function, method, and event handler.

    JavaScript: The Definitive Guide also includes a chapter that explains how to use the LiveConnect feature of Netscape Navigator 3.0 or higher. This feature allows JavaScript to communicate with Navigator's Java Virtual Machine. For more information about this book, visit O'Reilly and Associates's WWW site ( You can also call 1-800-998-9938 or 1-707-829-0515.

  • The JavaScript Authoring Guide ( Netscape, the company that developed the JavaScript language, provides complete online documentation of this language. The JavaScript Authoring Guide provides a concise description of JavaScript concepts and offers a JavaScript reference guide that includes descriptions of JavaScript objects, methods, functions, properties, and event handlers.

  • Instant Java by John A. Pew (ISBN 0-13-565821-7). Instant Java is a Java resource for nonprogrammers. If you want to create dynamic HTML elements such as animated text and graphics, slide shows, and audio clips, you will find everything you need in this book, including complete Java programs on a CD-ROM. You will also find detailed, step-by-step instructions on how to customize the Java applets on the CD-ROM to fit your specific needs. For more information about this book, visit Prentice Hall's WWW site ( You can also call 1-800-811-0912 or 1-515-284-6751.

  • Java: The Complete Reference by Patrick Naughton and Herbert Schildt (ISBN 0-07-882231-9). If you want to learn how to use Java, this book is an excellent resource. Beginning programmers can quickly learn the concepts of object-oriented programming and find out how to write, compile, and run Java applications.

    Intermediate and advanced programmers can start with the description of the Java language and follow the numerous sample programs to learn how to use more advanced features of Java, such as the Abstract Windows Toolkit and multithreading. For more information about this book, visit Osborne/ McGraw-Hill's WWW site ( You can also call 1-800-262-4729 or 1-510-549-6600.

  • The Java Class Libraries: An Annotated Reference by Patrick Chan and Rosanna Lee (ISBN 0-201-63458-9). After you start programming in Java, you will need a reference so that you can efficiently use the Java class libraries. The Java Class Libraries: An Annotated Reference includes detailed descriptions of all of the Java class libraries and hundreds of sample programs showing you how to implement various features of the objects and methods found in these class libraries. For more information about this book, visit Addison-Wesley Corporate and Professional Publishing Group's WWW ( or call 1-800-822-6339. Outside the U.S. and Canada, call 1-617-944-3700, ext. 5190.

* Originally published in Novell Connection Magazine


The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.

© Copyright Micro Focus or one of its affiliates