Scripting for Servers

Dreamweaver MX is an HTML authoring tool and an application development tool that interprets multiple scripting languages to build data-driven websites. It runs on Windows and Mac systems and interacts with the majority of development operating systems. Dreamweaver MX supports most scripting languages, application servers, and database formats. In addition, Dreamweaver MX provides an easy-to-use graphical interface that integrates all these components.

Throughout this book, you'll see the term script in many forms. In a nutshell, a script is a set of statements pertaining to a particular scripting language. In this context, a scripting language is similar to any other language in that it's a combination of keywords, functions, and methods. However, scripting languages are considered interpreted languages. That means the server parses, compiles, and then executes the script all at once and as needed.

An interpreted language differs from other programming languages, otherwise known as compiled languages, in one respect. A compiled language can parse and compile code before the code is executed. As a result, the compiled language stores an already translated version of the code.

In this book, we'll use a variety of scripting languages in our examples. You can learn more about the following scripting languages in Chapters 12 through 16.

Active Server Pages (ASP)

Eventually, the quest for more flexible web languages led to several scripting languages. ASP is a server-side, language-independent scripting host from Microsoft. That means ASP interprets most scripting languages. In fact, ASP works with any scripting language that has a certified ActiveX Scripting Engine. The one requirement is that the language be compatible with the Microsoft Scripting Host. The following scripting languages are compatible with the Scripting Host:

VBScript A subset of Visual Basic for Applications (VBA). We mention this one first because it's the default ASP scripting language.

JScript Microsoft's counterpart to JavaScript. Neither is connected to Sun's Java language. Many developers consider JScript the common standard for browser scripting. JScript comes with ASP.

PerlScript A subset of Perl, which has been around for a long time. It's used mostly with text. It doesn't come with ASP, but you can download it from www.activestate.com.

ASP.NET

Active Server Pages has been the Microsoft web staple for many years and has been supported in all prior versions of Dreamweaver MX (Drumbeat and Ultradev). ASP.NET is a complete rewrite of ASP for the .NET framework and provides many advantages over standard ASP. ASP.NET supports new providers when working with databases, particularly with Microsoft SQL Server 2000. Unlike standard ASP, which restricted the developer to working in VBScript or JScript, ASP.NET allows you to choose virtually any scripting language.

Don't confuse ASP (discussed in the previous section) and ASP.NET, because they aren't the same thing. However, ASP.NET is compatible with ASP to the extent that almost all ASP code is supported in ASP.NET (for now) for backward compatibility.

Hypertext Preprocessor (PHP)

PHP is another server-side scripting language that puts dynamic capabilities into the hands of the masses. PHP runs on Linux, many Unix variants (including HP-UX, Solaris, and OpenBSD), Microsoft Windows, Mac OS X, and RISC OS. Supported web servers include Apache, IIS, PWS, Netscape, and iPlanet. For the most part, you'll find PHP running on Apache servers and interacting with MySQL (a database), although PHP supports a number of databases, including dBase, IBM DB2, Oracle, and Sybase. Currently, PHP is an open-source language that can be freely distributed. You can download PHP at www.php.net.

In a nutshell, you insert PHP code inside your HTML code. When a client makes a request, your server executes the PHP code, just like any other scripting language. PHP's many capabilities include the following:

  • PHP supports data-driven applications and supports cookies (or we wouldn't include it in this discussion).

  • PHP authenticates and tracks users.

  • PHP supports threaded discussions at your site.

  • PHP is scalable across multiplatforms.

  • PHP supports Extensible Markup Language (XML).

  • PHP supports command-line scripting, which is ideal for scripts regularly executed by an operating system.

JavaServer Pages (JSP)

JavaServer Pages is an application server that uses XML-like tags and Java-based scripts to generate web pages. The technology is platform-independent and consists of Java server-side modules, known as servlets, that support and extend the web server. JSP is available for free from Sun Microsystems at http://java.sun.com/products/jsp/download.html.

JSP pages consist of three elements:

  • Static components-HTML or XML

  • JSP tags (unique to JSP)

  • Java code, known as scriptlets to the Java developer

Anyone knowing HTML or XML should pick up JSP quickly. In fact, part of its appeal-and hence its growing market share-is its simple language. You don't have to be an experienced web developer to successfully use JSP.

If you're a Sun developer or if you're already familiar with Java, the jump to JSP will be painless. On the other hand, if you're coming from a Microsoft background, you'll find JSP very different from ASP. The main differences boil down to differences in shop technology-you're Sun or you're Microsoft. You can use JSP with Windows and IIS, but you can't use ASP with Sun.

The JSP engine is really a specialized servlet, supported by the servlet engine. JSP only deals with text, so you must use servlets to communicate with Java applets and applications. As a result of this arrangement, you may find servlets better suited to nondynamic tasks such as authentication, validation, and so on. Rely on JSP pages for your data-driven content.

Unlike most of the scripting languages we've reviewed, JSP code is stored separately from the static presentation within external JavaBeans components. The JSP page uses special tags to call these components as they're needed. When a change is made to the presentation template, the JSP engine automatically recompiles and reloads the JSP page.

JSP consists of three components: directives, scripts, and actions. Directives tell the JSP engine what to do with the JSP page. These directives are enclosed with the %@...% tag. Fragments of Java code, known as scriptlets, are enclosed in the <%...%> tag. Actions perform tasks such as instantiating objects and communicating with the server.

ColdFusion MX

Macromedia's ColdFusion MX is a web application server that lets developers create scripts for controlling data integration, logic, and user interface components for a website. In other words, Cold- Fusion MX processes the logic and scripting in your page and then lets your web server build the HTML to hand back to your user's browser.

Note 

An application server is a server that supports your web server. When your browser requests a ColdFusion MX page, your web server passes that request on to the ColdFusion MX application server, which then processes the request and hands it back to the web server for delivery to your browser.

Using ColdFusion MX, you can quickly produce dynamic web pages without actually writing your own scripts-which can be tedious work even for the experienced web developer. This makes Cold- Fusion MX or any similar product the ideal solution for the nonprogrammer.

ColdFusion MX quickly produces HTML-like tags via its many wizards and auto-generating tags. For instance, you can combine ColdFusion MX tags to automatically generate a validation script (which you'd otherwise have to write yourself). The automatically generated script is ColdFusion Markup Language (CFML)-a tag-based server scripting language like HTML. You can download a demo copy of ColdFusion MX from www.macromedia.com.



Mastering Dreamweaver MX Databases
Mastering Dreamweaver MX Databases
ISBN: 078214148X
EAN: 2147483647
Year: 2002
Pages: 214

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net