Technologies of server programming languages ​​and databases. Web programming languages: Client and Server

Web mastering. Server web programming

In the ranking of the most attractive and in-demand professions in IT, we can confidently put webmasters in first place - this word broadly refers to specialists who develop and support websites. Today, any serious company strives to acquire its own website or web page, which means it needs qualified specialists.

Developers, programmers, layout designers, optimizers are valuable employees in Russian and international companies. They are offered a decent salary and attractive working conditions: corporate benefits, interesting projects, career growth, flexible schedules. Thanks to the stable demand for his services, a webmaster can afford to work as a freelancer: choose clients himself, without reporting to his “uncle,” sitting in his favorite chair at home or in a hotel by the sea.

If you decide to develop websites, you need to clearly understand the principles of how a web server works. It is knowledge of the HTTP protocol that makes a webmaster a professional in his field and allows him to easily solve website building problems. A specialist who neglects this fact, when faced with a problem, writes cumbersome program code and does not even realize that it can be solved with one or two lines in the web server configuration.

Our course "Web mastering. Server web programming" will help you study the mechanisms of a web server and gain practical administration skills. It will be useful to graduates of direction courses PHP, ASP.Net etc. and for students who are just planning this training. The course may be recommended to graduates of web-based courses if the students have not taken the actual course.

During the classes you will look at the IIS server, which is part of the line OS Windows 8/7 And Windows Server 2012/2008, as well as the server Apache versions 2.2-2.4, often used on the platform Unix. The teacher will pay attention to important topics related to security: authentication mechanisms, user authorization scenarios, setting up and using SSL, working with SSL certificates, using the Apache mod_rewrite server module.

You will put the acquired knowledge into practice: The 24-hour course includes 13 laboratory works. After completing the course, you will be able to independently administer IIS and Apache 2.2-2.4 servers, manage content caching, use SSL and work with RFC specifications. Your skills and abilities will be confirmed by the center’s prestigious documents: a certificate and a certificate of advanced training.

A successful web programmer career starts with this course! Sign up for the course!

Upon completion of the course you will be able to:

  • Know and understand the HTTP/1.1 protocol
  • Administer IIS server
  • Administer Apache server 2.2 - 2.4
  • Manage content caching
  • Use server handlers and modules
  • Understand user authentication mechanisms
  • Use SSL
  • Work with RFC specifications
Specialists with this knowledge and skills are currently in great demand. Most of our course graduates go on to successful careers and are respected by employers.

Salesman

To view the content you need

Programming languages ​​that allow you to work with Internet technologies are called web programming languages ​​(hereinafter referred to as WPLs for convenience). Some of them were once created specifically for specific resources and became widely known much later. PHP, for example.

WEB programmingAll languages ​​are divided into server and client:

Client web programming languages


Programs written in client languages ​​are processed by the browser. In other words, they are processed by the user's client. Hence the name. Hence the disadvantage: how the program (script) is processed directly depends on the browser. The user can even set it to ignore your script completely.

In addition, a browser that is too old may not support the language or version of the language in which the program is written. But here, however, it is worth saying that this happens quite rarely, since nuclear warheads are not updated very often.

The program code of a script created on a client-side language can be viewed by anyone, for example, by right-clicking on the page and selecting “View page code” or something similar from the context menu (depending on the browser).


The advantage of client scripts is speed. Let's say the program must check the data entered by the user on VKontakte for correctness. In this case, the check will be performed immediately, without sending what is being checked to the server and without receiving the report back. The time savings are obvious.

But this is the downside - the client script cannot write anything to the server at all. Therefore, it will not be possible to create, say, a guest book using a client-side language program, because to do this you need to save messages in a file on the server.


Examples of Javascript include Java Script, which had a significant influence on the development of C-Sharp (here is the C# forum), and Visual Basic Script. To study client languages ​​and work with them, you need a browser that supports them. For example, Internet Explorer, Mozilla or Opera are suitable.

Server-side web programming languages


A server is a computer on which a website is hosted and software that processes browser requests to website pages.

The processing of scripts on server-side languages ​​differs from client-side ones:
the user tries to go to the page (enters the URL in the address bar or follows a link);
all scripts associated with this page are processed on the server;
An HTML document is displayed to the user.

That is, a page visitor will not be able to see the script code on the server-side language. Thus, the performance of the script now directly depends not on the user’s browser, but on the server on which the site is hosted.


It is also worth mentioning the concept of DBMS (Database Management System). In general, this is also a server. When purchasing hosting, the website creator receives a Database (DB), in the tables of which it can store various information that can be accessed at any time. If we return to our example, one of these tables may contain user messages left in the guest book.

Of course, someone will say that messages can also be stored in a text file. But information stored in the database is easier to manage - you can link tables, store encrypted passwords, and much more.

The functionality of server-based languages ​​is almost limitless, but learning them is quite labor-intensive, no matter what the language creators say.


Recently, DBMSs have become widely used; they are accessed through a structured query language - Structured Query Language (SQL). Obviously, working with such databases requires direct knowledge of SQL. Such DBMSs include, for example, MySQL and PostgreSQL.

Among server-side languages, the most common ones are PHP, SSI and Perl.

To study server-based languages ​​and work with them, you need a little more than for client ones - a server, a language interpreter and a DBMS.

In general, from all of the above, we can conclude that for simple scripts or for novice webmasters, any of the client-side Java programs is perfect. For more serious developments, you will have to learn a server language.

Did you know that web programming languages ​​can be client-side or server-side? JavaScript, VBS, PHP, PERL. Do you know how they differ and how they work? Do you know what a server is? Do you know what a DBMS is? Do you know? So read this article and find out :)

1 - Web programming languages, what are they?
2 - Client-side web programming languages
3 - Server-side web programming languages
4 - A few final words

Web programming languages, what are they?

You read somewhere that in order to create a guest book or a survey, you need to know some kind of web programming. Have you ever heard what web programming is? So we met, because I was once also tormented by these questions, and now I will try to give answers to them.

Web programming languages ​​are, respectively, languages ​​that are primarily designed to work with Internet technologies. And some were created only to work with some resource, and only a long time later they gained fame and universal recognition (for example, PHP). But I will not delve into the history of the creation of various web programming languages, since it is not the subject of this article, and if the reader is interested, he can find it on the developer sites.

Web programming languages ​​are divided into two groups: client and server. Let me remind you what a server is: this is both the computer where your website is stored and the program that processes browser requests for any page.

Client languages

As the name suggests, client languages ​​are processed on the user's client side, and, to put it simply, programs in the client language are processed by the browser. The downside to this is that script processing is dependent on the user's browser, and the user has the power to configure their browser to generally ignore scripts you write. However, if the browser is old, it may not support the particular language or version of the language you are relying on. With modern browsers such problems should not arise, besides, programming languages ​​are not radically updated very often (every few years) and the best of them have long been known. Also, anyone can view the client script code by selecting the “Source Code” tab in the “View” menu of their browser (or something like that).

The advantage of a client language is that scripts in such a language can be processed without sending a document to the server. This is easier to explain with an example: let’s say you need to check whether the user entered the e-mail correctly (i.e., for example, check for the presence of “@”); To do this, the user would have to send a form with filled in data, then wait until it is processed, and only then receive an error message (if, of course, there is one). The process is too long. With the client language, the program will immediately check that the form is filled out correctly before sending, and, if necessary, display an error. This also leads to the limitation that using a client programming language nothing can be written to the server, that is, for example, you cannot use it to create a guest book, because then you need to write messages to some file on the server.

The most common client language is JavaScript, developed by Netscape (www.netscape.com, I think you know their Netscape Navigator browser) together with SunMicrosystems (www.sun.com). Another client language option is, for example, VisualBasicScript (VBS). To start learning a client web programming language, you will need a browser that supports this language (Internet Explorer (www.microsoft.com), Opera (www.opera.com), Netscape Navigator (www.netscape.com), Mozilla (www.mozilla .org), would be suitable options (personally, I use the latter)) and training material, which can be found on the website alepira.ural.ru

Server languages

So, now let's look at how scripts are processed in a server-side programming language. To begin with, I will provide the following diagram:

When a user makes a request for a page (follows a link to it, or enters an address in the address bar of his browser), the called page is first processed on the server, that is, all scripts associated with the page are executed, and only then returned to the visitor in the form of a simple HTML document (that is, the visitor will no longer be able to see the code of your script). But the operation of your scripts is completely dependent on the server on which your site is located, and on which version of a particular language is supported by the hosting.

Server-side programming languages ​​open up a wide range of activities for the programmer, however, no matter how much people promoting the language write that their language is very easy to learn, it is quite difficult to master without a preliminary load of knowledge.

Here it is worth mentioning what a Database Management System, or DBMS, is. This, in fact, is also a server on which various necessary information is stored in a user-defined order, which can be called up at any time. This is a library in which all materials are neatly stacked on shelves and can be taken out at any time. Usually, when purchasing hosting, one Database (DB) is allocated, in which the user can create many tables, and store a variety of information in them. That is, if we return to the example with the guest book, then in any table you create you can store messages left by users. You can, of course, store them in a text file, but this is less reliable, and besides, I gave only a small example, and if, say, you need to store passwords (and they need to be stored in encrypted form), or link several tables when When accessing any data, you cannot do without a database.

Currently, DBMSs have become known, and for good reason, which are accessed using Structured Query Language (SQL), or a structured query language. To work with these databases (augment, update, make queries, etc.) you need to know this very SQL. Among such DBMSs, the most famous is MySQL (www.mysql.com), but for myself I preferred PostgreSQL (www.postgresql.org).

A few final words

If we continue to talk about programming languages, now there are languages ​​that are built into the document itself, and those programs in which you must first compile, that is, turn the source codes you write into a finished program; the disadvantage of the latter is that if you need to update the script, you will have to recompile the updated codes.

Among the server programming languages, PHP (PHP: Hypertext Preprocessor) (www.php.net), Perl (www.perl.com), SSI (Server Side Include) stand out. To test these scripts, you will need more: a server (www.apache.org), a language interpreter (you can get it on the manufacturer’s website), and of course, for productive work, also a DBMS.

What? What other server programming? What kind of trouble is this? And why do we need it?

We seem to have learned how to create Web pages in the Dreamweaver environment. We even learned how to create entire Web sites using it and publish them on a Web server. We studied two types of page design: frame-based, when sites are built based on sets of frames, and tabular, when page content is placed in a large, complex table. We learned about style sheets, meta tags, and server-side directives. And finally, we learned about Web programming and Web scripts that allow us to add “life” to our static pages. What else is needed for happiness?

Yes, what we learned earlier is quite enough for us to create quite decent websites. Many Web designers stop there. But we want more, don't we?

So let's take the next step - let's move from pages stored in files on the server to pages generated by special programs. It is precisely the writing of such programs that server programming deals with.

But let's take things in order. And we’ll start by finding out why these server programs are needed.

What is server programming

Really, what is it and what is it eaten with?

Why do we need server programs?

Have you ever visited an online store? For example, the most popular "Ozone" (http://www.ozon.ru). Do you remember how to order goods there?

If you don’t remember or don’t even know what an online store is, let’s remember (or find out).

You go to a Web page that describes the product you need. After much pangs of conscience, you finally decide to buy and click on the button Buy. After this, you receive several Web pages where you can set your address, methods of payment and delivery of goods, and, finally, confirm the purchase. You do all this by clicking the appropriate buttons and entering data into the appropriate input fields located right on the pages.

What happens when this happens? How is the data you enter processed? Is it really the Web browser itself?

Not at all. This data is processed on the Web server.

An online store is just one of the examples that came to the mind of the author, who is a fan and regular customer of the above-mentioned “Ozone”. Web-based email servers, search engines, electronic bulletin boards, forums, and, in general, any Web sites that receive some data from the visitor and process it work in exactly the same way. In all these cases, the Web browser receives data from the visitor and sends it to the Web server, which processes it and produces the result of processing in the form of an automatically generated Web page.

How does this actually happen? Now we will find out. And first of all, let's answer the question...

Like a Web server processes user data

So how does a Web server program process data sent to it by a user?

No way. The Web server is not equipped to process them. Its task is to receive a request for files from a Web browser (Web pages, style sheets, graphic images, movies, sounds, archives, executable files, etc.), search for these same files on the hard drives of the server computer and send the found files back to the Web browser. This is his main task. Of course, some particularly powerful servers can perform additional actions on the files being sent before actually sending them (in particular, executing server directives). There are also “multi-host” programs that perform the functions of not only a Web server, but also an FTP server, mail, UseNet news, and God knows what else. But the main function: simple issuance of files according to customer requirements - and nothing more.

The secret is that the visitor data is not processed by the Web server itself. To do this, special programs are used that work together with the Web server on the same server computer. They're called server programs, do not have a user interface and “communicate” only with the Web server, receive data entered by the user from it and return the result to him. This is how they fundamentally differ from client programs that work directly with the user. (Client programs include, but are not limited to, your favorite Web browser.)

It follows from this that the Web server can still accept data from the user. Yes, this is part of its main task: to accept data and redirect it to the server program. In turn, the server program will process them and return the result to the Web server.

This is where the fun begins. The fact is that the result returned by the server program to the Web server is nothing more than ordinary HTML code! In fact, the server program returns a finished Web page generated based on the data entered by the visitor. This page is called dynamic, Unlike static pages written by a Web designer and stored in files on the disks of a server computer. And the Web server sends this dynamic page to the client as a response to the entered data.

Server programs are divided into the following four types.

  1. Executable programs running through the interface CGI(Common Gateway Interface - common exchange interface), the so-called CGI programs. This type of server software is the oldest, but by no means obsolete.
  2. Web Server Extensions(ISAPI, NSAPI format applications, Apache extension modules, etc.). A new method that allows you to embed server programs into the Web server itself, making them its integral parts. It was first proposed by Microsoft for their Microsoft Internet Information Server (ISAPI interface) and by the developers of the popular free Apache Web server.
  3. Active server pages(ASP, JSP, etc.). In fact, these are ordinary static Web pages saved in files, which, in addition to the usual HTML code, include commands processed either by the Web server itself or its extension. Also a new method, first proposed by Microsoft for the same Internet Information Server.
  4. Server scripts, written in an interpreted language (Perl, Python, VBScript, JavaScript, etc.). Common scripts running through a CGI or ISAPI interface on the server side.

Now let's look at all this diversity in more detail.

CGI programs are ordinary executable files written in any programming language and compiled into software.processor bus code. They do not have a user interface (like all server programs), but work with a Web server, receive input data from it and send the results of their work to it. They are launched by the Web server itself when they are needed (when it is necessary to process data received from the user), and work under the control of the operating system of the server computer. Moreover, if the Web server simultaneously receives several requests for data processing from users, it launches the corresponding number of copies of the CGI program.

The advantages of CGI programs include ease of creation (many program development environments support the creation of such applications, in particular the popular Borland Delphi, starting with version 3) and ease of debugging. Also, because CGI applications are independent programs, they run separately from the Web server (as programmers and system administrators say, they run in a different address space). This means that if a CGI program fails, only that program ends - the Web server itself remains afloat. But CGI programs have only one drawback: a large consumption of system resources, since a separate copy of the server program is launched to process each set of data. And if the Web server receives too many requests to process data, the server computer may freeze.

Web server extensions are a newer type of server software. They are ordinary DLLs that implement all the logic of the server program. Such libraries are built into the Web server program and work as an integral part of it. Since DLLs only work in the Windows environment, other formats have been invented to create extensions on other operating systems. In particular, Apache server extension modules are not DLLs,

It is in the form of DLLs that extensions of the Web servers Internet Information Server from Microsoft and Netscape Web Server from Netscape are created. In the first case, extensions have the format ISAPI(Internet Server Application Programming Interface - Internet server application programming interface), and in the second - NSAPI(Netscape Server Application Programming Interface - Netscape server application programming interface). The format of Apache extension modules is called Apache modules.

Web server extensions have one advantage: careful consumption of system resources. The fact is that to process all sets of user data, only one instance of the extension is launched, which takes up significantly less resources than a lot of running CGI programs. However, extensions are more difficult to create and debug, and they are not as secure.

Like CGI programs. Since they run as part of a Web server, any error in the extension will cause the server to hang.

Both types of server programs described above have one huge drawback. Before they can work, they must be written in a programming language and compiled into machine code on the processor, which is time-consuming, especially when debugging. Of course, compiled programs work faster than interpreted ones, that is, those where each instruction is read, decrypted and processed by a special interpreter program. But interpreted programs also have their advantages, the main ones being simplicity and speed of writing. The next two types of server programs that will be described will be interpreted.

As already mentioned, active server pages are ordinary Web pages that include special server scripts, executed by the Web server itself or a special server program (CGI application or Web server extension). In particular, A.S.P.(Active Server Pages) supported by Microsoft Internet Information Server, and JSP(Java Server Pages - server pages written in JavaScript), supported by a number of other Web servers, work in this way. ASP server pages are written in JavaScript and VBScript, while JSP is written only in JavaScript.

You already know the advantages of active server pages: ease and speed of writing and ease of debugging. Additionally, since active server pages are just regular Web pages with code sprinkled in, they can be written easily by anyone familiar with HTML. Disadvantage: relative slowness and increased demands on system resources.

Server-side scripts are similar to active server pages in that they are interpreted, but they are "pure" program code, without HTML additives. The interpreter is almost always a CGI program, but there is nothing stopping you from developing it as a Web server extension Scripts are usually written in the Perl programming language, which is specifically designed for text processing; Python, JavaScript, VBScript, and even (as they say) the MS-DOS command file language are also used. In fact, you can write scripts in any programming language for which there is an interpreter.

The advantages and disadvantages of server-side scripts are the same as active server pages. However, scripts consume an exceptionally large amount of system resources, even more than CGI applications. After all, to process each set of user data, its own copy of the interpreter is launched, and the interpreter, in turn, spends a lot of resources on processing the script. And yet, despite this, scripts are the most popular way to create server programs.

In table 15.1 shows the file extensions of server programs.

Table 15.1. Server program file extensions

Type of server programs

Subspecies

Extension

CGI programs

-

exe

Web Server Extensions

ISAPI and NSAPI Apache Modules

dll No extension

Active server pages

Server scripts

ASP JSP

asp jsp

Language Perl JavaScript VBScript Other languages

pl, cgi js, cgi vbs, cgi cgi

So we looked at how the Web server processes (or rather, does not process) user data. Now let's move to the beginning of the chain and look at how the Web browser sends user data to the server program.

How the Web browser sends the entered data

At the beginning of this chapter, we talked about how controls placed on the Web pages themselves are used to collect visitor data. These are ordinary controls familiar to you from Windows applications: input fields, buttons, lists, checkboxes, etc. A site visitor enters data into them and presses a special button that starts sending the data to the Web server, and therefore to the server program.

Controls for entering visitor data are placed on the form. Form - This is a special element of the page that actually encodes the data and sends it to the Web server. (We can say that the form is the parent of the controls.) The controls themselves only receive data from the visitor, but do not encode or transmit it.

Each control on a form must have a unique name. These names are used by the Web browser to present the data entered into the form in a way that is readable by the server.

For example:

Here we have considered the ideal case where the values ​​of each control contain only valid with from the point of view of the HTTP protocol, symbols: letters of the Latin alphabet, numbers, dashes, underscores and some other characters. (Remember, HTTP is a file transfer protocol used by a Web server.) If you transfer data that contains illegal characters, such as spaces or letters of the Russian alphabet, each such character will be represented as a hexadecimal code, preceded by a percent sign, for example, like this (encoded space characters are in bold):

Thanks to this data format, writing server programs that process it becomes very simple. In particular, Perl has built-in decryption facilities for this format.

The data presented in the above form is subsequently encoded using one of the predefined coding methods and are sent over the Internet to the server program. All this is actually done by the form (but not the controls).

The process of sending data begins after the user presses a special button. This button is called Send(Submit - in English-language programs) and must be present in the form. The form may also contain a button Reset(Reset), which resets the data entered by the user. Typically, these buttons are located at the very bottom of the form.

You can think of a form as something like a regular Windows application dialog box that accepts input from the user, encodes it in a specific way, and sends it to the main window. (Dialog windows of Windows applications also necessarily have two buttons: OK And Cancel(Cancel).) But if in the case of a regular Windows application the programmer must explicitly specify how the data will be encrypted and sent, in the case of a Web form this does not need to be done. You will only need to set three required parameters:

  • Internet address of the server program that will process the form data;
  • encoding method for sent data;
  • one of two methods for sending data.

We'll talk about methods for sending data a little later. Now let's find out everything about the other two required form parameters.

The Internet address of a server program is very similar to the Internet address of any other file, such as a Web page. Take a look for yourself - this is what the address of the CGI program will look like:

http://www. somesite. ru/bin/program.exe This is the address of the Web server extension: http: //www.somesite.ru/bin/extension.dll This is the address of the active server page:

http://www. somesite. ru/asps/active_page. asp

And this is the address of the script program written in Perl:

http://www. somesite. ru/scripts/perl_script.pl

As you can see, there is nothing complicated about this. A server program is an ordinary file placed on the hard drives of a server computer, and a link to it also does not represent anything special.

To encode data transmitted over the Internet, the three most popular methods are usually used: application/x-www-form-urlencoded,multipart/form-data and (much less often) text/plain. It is possible to use other encoding methods, but in the vast majority of cases the three listed are used. In addition, these three encoding methods are supported by most Web browser programs.

Note

If you still remember what a MIME data type is, then, looking at the names of data encoding methods given above, you will immediately see that these are just MIME types. It is with their help that coding methods are specified.

In the vast majority of cases, the application/x-www-form-uriencoded encoding method is used. By the way, it is the one that is used by default if the encoding method is not specified. The multipart/form-data encoding method is used if you are going to send files to a Web server; it provides the binary data conversion appropriate for this case. The last method - text/plain - presents the data in plain text, which can be useful if the form data will be sent by email (sometimes this method of data transfer is also used).

So, we've sorted out the data encoding. It remains to be seen how this data is transmitted over Network channels.

How data is transferred over the Internet

As you already know, to send data over the Internet, and indeed over any local or global computer network, a special set of rules is used, called protocol. The protocol defines how data will be encrypted and packaged for subsequent transmission over the network. Naturally, both the sending and receiving programs must support the same protocol in order to “understand” each other. (Otherwise, so-called incompatibility with the data transfer protocol will arise, a very unpleasant thing.) Actually, we have already talked about Internet protocols and there is no point in repeating them now.

You also know that the HTTP protocol is used to send Web pages and associated files (graphics, sounds, archives, etc.) over the Internet. It is also used for data transmission, and for this there are two transfer method data. Both methods are widely used in Internet programming and have their advantages and disadvantages. Let's look at them.

The first method is called GET by the value of the corresponding form parameter. When used, data is transmitted as part of the Internet address in an HTTP request.

As you remember, a Web browser, in order to receive the file it needs from a Web server, sends this server a so-called HTTP request, which includes the Internet address of the required file. So, the data can be transmitted as part of this address.

Take, for example, the data set shown just above:

name1 = Ivan surname = Ivanovich name2 = Ivanov age = 30

Now let’s prepare it for sending using the GET method (the data itself is in bold):

http://www.somesite.ru/bin/program.exe? name1=Ivan&surname2=Ivanovich&name2=Ivanov&age=30

As you can see, data sent using the GET method is placed at the very end of the Internet address and is separated from it by a question mark. In this case, the “name” = “value” pairs are separated from each other by the “commercial and” sign (“&”). Everything is very simple and clear.

This simplicity and clarity of data presentation is the main advantage of the GET method. As they say, everything is in plain sight. Debugging Web pages is also greatly simplified: since the address passed to the Web server is displayed in the address bar of the Web browser, you can always see what exactly was passed. (However, as you understand, confidential data cannot be transmitted using this method - everyone who stands behind your back will see it.)

http://www.mysite.ru/bin/choose.exe?chapter=3

As you can see, these are actually links to the server program, containing one chapter parameter and its value. This means that all other pages of such a site are formed dynamically by the server program, based on the received parameters. Using this principle, directory sites, program catalog sites, electronic stores and other sites containing a large amount of classified information are often built.

Unfortunately, the GET method has a huge disadvantage: it cannot transfer large amounts of data. This is due to the limitation imposed by standards on the length of an Internet address: no more than 256 characters. Subtract the length of the actual address of the server program from here - and you will get the maximum allowable size of your data. The second disadvantage of the GET method is the flip side of its advantages. The data it sends is publicly visible and can be easily read in the address bar of a Web browser.

The GET method should be used if the data sent to the server program is obviously small and not secret. In particular, it is used to send keywords to search engines in sites built on the basis of a server program (see above) etc. If you need to send voluminous or confidential data, use the second transmission method, called POST.

Method POST transmits data to the server program in the same HTTP request, but not as part of the Internet address, but in the form of so-called additional data. Since the size of the additional data is not limited (at least it can be very large), you can transfer anything you want, in any quantity. In particular, even files can be transferred to the Web server in this way.

Advantages of the POST method: there is no limit on the volume of transferred data and its “invisibility”. Disadvantages: difficulty in decrypting data and difficulty in debugging. The POST method is used to transmit, for example, personal data, addresses of customers in electronic stores, literary worksaccess to the sites http://www.stihi.ru and http://www.proza.ru, etc. In general, something that has large volumes.

As they say, the WWWC committee intends to eventually abandon the GET method altogether and transfer all data using the POST method. So far, the GET method has simply been declared not recommended for use in newly created sites, but in reality it is still supported by Web browsers.

So we found out everything about server programs. Well, maybe not all, but for now this is enough for us. Now let's talk about how fully all this is supported by Dreamweaver MX.

Server-side programming - the Dreamweaver approach

Is it difficult to write server programs? Yes, it is difficult. Probably even more difficult than Web pages.

However, remember how often we had to write HTML code by hand? Quite rare, isn't it? And all because Dreamweaver carefully protected us from this by providing a convenient interface for visually creating pages. We simply wrote text, formatted it, placed images, tables on the page, applied behaviors to page elements, etc. In a word, we felt comfortable.

And will we really now have to write server programs manually?! No, not at all necessary.

It has already been mentioned that Dreamweaver provides so-called behaviors for inexperienced users and generally for those who do not want to deal with JavaScript code. Behavior- this is a ready-made script, written by professional programmers and placed into the web page code by Dreamweaver itself after the user selects this behavior in the panel behavior menu Behaviors. The user does not have to worry about placing a script that performs this or that action in a certain place in the page code; he will not need to check this script for errors and coordinate it with other scripts. Dreamweaver does all this for him.

In fact, the set of operations used in server programming is very small. Open the database, get some data from it, display it on the page, write new data - what else is needed!

Of course, if you want to do some fancy stuff, you'll have to write server pages hand-to-hand. But, you see, this doesn’t happen often.

So we found out two things. First, Dreamweaver MX supports the creation of server-side Web pages. Second, it uses behaviors you are familiar with to put scripts into them. Dreamweaver offers a large set of behaviors for server-side scenarios that should be enough for you to get started.

It remains to be seen which server pages Dreamweaver allows you to create. More precisely, what technologies for creating server pages it allows you to use. There are four such technologies, and they will now be listed.

  1. ASP. This technology is already familiar to you.
  2. ASP.NET. Further development of ASP.
  3. PHP. Free technology distributed with open source texts. Quite popular and often used with free Web servers, such as Apache.
  4. Macromedia ColdFusion. Own development of Macromedia.

Which one should you choose? After all, we will need to create examples of Web pages.

Let's choose ASP. And that's why.

In order to work with server-side pages, we need a Web server. Without it, server pages simply won't work. And perhaps you know that all more or less new versions of Windows come with a small Web server. On Windows 95/98/ME systems it is Personal Web Server, and on Windows NT/2000/XP it is Internet Information Server. Its capabilities are quite enough for us to experiment with server programming.

So, this Web server fully supports ASP technology. You can write active server pages and execute them under it. And you won't have to download any additional components - everything you need is already included in the Windows distribution kit. That's why ASP was chosen.

Almost no Web server currently supports ASP.NET technology; Microsoft has not yet released a single product that supports this technology. To work with PHP pages, you will have to search and download on the Internet a fairly large distribution kit containing a PHP handler, and then spend a lot of time setting it up. As for ColdFusion technology, you are unlikely to be able to shell out several thousand dollars for it. So we have practically no options.

Introduction to Databases

The last thing we'll look at in this chapter is databases and working with them. Since the lion's share of server programs works with databases, this knowledge will be very useful to us. Of course, we will not consider all database technologies in detail, but, as before, we will limit ourselves to a brief educational program. You yourself can search for the necessary books and texts on the Internet if you are interested in this.

What's happened database? Nothing special, just a regular file or group of files containing data organized in a special way. If a database consists of many files, it still remains a single entity. The data contained in the database is processed using a special program called database processor. The database processor can be either a completely separate program running on the same computer as the program using the data, or be part of it.

Databases can be organized in different ways. But the vast majority of databases in use today are relational. Data in such databases is organized in the form of tables. Each such database may include one or more tables; complex databases typically have many tables interconnected.

Each table, in turn, consists of a set of rows divided into cells, and each cell contains data of a certain type: text, numbers, logical values, dates, etc. The rows of database tables are called records, and the cells into which each record is divided are fields. As already mentioned, each field has a specific type and is necessarily equipped with name, through which the program working with data accesses this field.

In Fig. 15.1 shows an example of such a table. As you can see, this table has three fields:

  • NAME - name of the technology for creating server pages, text;
  • PRICE - price of the handler program, numeric;
  • USING - whether this technology is currently supported, logical ("yes-no").

In addition, this table has four entries corresponding to the technologies supported by Dreamweaver MX: ASP, ASP.NET, PHP, and ColdFusion.

Very often one of the table fields is done key. The key field value is used to uniquely identify a record. Of course, the key fields of all table records must contain unique values ​​in this case. Sometimes the key field is called counter field.

Example of a table included in a database

You already know how to access a separate field - by its name. How can I access the required record?

The fact is that at one time a program using database data can only work with one record, called current. It can retrieve data from the fields in that record and possibly modify them. But to get the data of another record, the program must issue a move command. In this case, the database processor moves a special current record pointer to the desired record, and the program is able to work with it.

The program can also use search the desired record according to any criterion. Very often, such a search is performed using the value of a key field.

The program also has the ability to add new and delete unnecessary table entries. To add a new record, the program executes the command to add a record and enters the necessary data into its fields. To delete an entry, the program must first make it current and then issue the delete command.

In general, the sequence of working with data contained in the database looks like this:

  1. Program opens database by performing an open operation. This is a necessary operation, without which it is impossible to access the database.
  2. The program opens the desired database table. After this, the processor returns to her the so-called recordset(in English -- recordset), with which the program works.
  3. The program does the actual work with the data.
  4. Program closes table, after which the processor removes the set of records corresponding to this program from memory.
  5. The program closes the database, breaking all connections with it.

Please note that the last two operations - closing the table and the database - are just as necessary as opening them. The fact is that a set of records and other data structures generated by the processor in memory for a program working with data take up a lot of system resources. Therefore, once you are done working with a table or database, close it immediately to free up resources for other users.

Recently, they have gained great popularity database servers. These are ordinary data processors, but implemented in the form of server programs and running on server computers. Their advantages over conventional data processors:

  • they run on a server computer, which is usually more powerful than the client computer, so their performance is higher;
  • they provide greater data security through access control and some other mechanisms;
  • they are simply more powerful, in the sense that they support more different innovations that have appeared recently.

To gain access to the database server and the data itself, the client program sends special commands to it. To compose such commands, a query description language was developed SQL(Structured Query Language - structured query language). Using commands written in this language, the client program can open the desired table, read the data, add, change, delete a record and, ultimately, close the database when it is no longer needed.

Database servers are now used very often, and in Web programming - almost everywhere. The most popular include Oracle, Microsoft SQL Server, Sybase, the powerful IBM DB2, Borland InterBase (in Russia it is sold under the name IBase), the increasingly popular PostgressSQL and the free MySQL server, distributed as open source. The latter server, by the way, is very often used in conjunction with the Apache Web server and PHP server page technology.

This concludes the story about databases and server programming.

It has already been said that special elements of Web pages - forms - send data to the server program. We will talk about forms and working with them in Dreamweaver in the next chapter. And then we’ll move on to server programming itself.

Suppose you have made a simple HTML website and you want to know the opinions of visitors about the content posted. What is needed for this? - that's right: give visitors the opportunity to leave their comments. This cannot be achieved using HTML or CSS. And this is where programs (also called scripts) created using web programming languages ​​come to the rescue.

It turns out: web programming can be called the creation of special programs for their use on the Internet. There are quite a few programming languages: C++, Perl, Java, Php, JavaScript, Python, Visual Basic and others.

Complexity programming languages different. The more complex a programming language is, the more capabilities it has. More complex web applications are written in more complex languages. All programming languages ​​can be divided into two camps: server and client.

Let's talk a little about terms. All information on the Internet is stored on remote computers called servers. The opposite side is network users who are looking for the information they need; they are usually called clients.

Client programming languages

The most common of them are JavaScript and Visual Basic. The peculiarity of such languages ​​lies in their name. Programs written in client programming languages processed on the client computer. To put it simply, scripts are processed by the browser on your computer. Their pros and cons follow from this feature.

The biggest advantage is that there is no need to send the web document to the server for processing. This feature significantly increases the script reading speed. Traffic is reduced, which saves money and reduces the load on the server. There is also no need to install additional software for processing scripts, because they are processed by browsers.

Flaws client programming languages also follow from the features. Different browsers may interpret scripts based on their individual preferences. Therefore, the results of displaying the same documents may differ. Although, recently the work of various browsers has become more and more unified. Another disadvantage is the openness of the code of such languages ​​for users.

Server programming languages

Server programming languages respectively work on the server side. In interaction with databases, they maintain communication between the user and the server. Receiving a request with the address of a web document from a browser, server programs contact the database. The database provides information about the web page to the server scripts, and after processing it, they send it to the client browser for interpretation, which displays the result of the joint work on the monitor.

A simplified diagram of such work is shown in the figure.