1. Trang chủ
  2. » Công Nghệ Thông Tin

Adobe Dreamweaver CS3 Unleashed- P20 ppt

50 598 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Adobe Dreamweaver CS3 Unleashed- P20 ppt
Định dạng
Số trang 50
Dung lượng 443,26 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Working with Server-Side TechnologiesIN THIS CHAPTER Working with the IIS Web Server Working with ASP Installing and Working with ASP.NET Installing and Working with ColdFusion Installin

Trang 1

The Dynamic Vecta Corp Intranet Application

Up to this point, we've used various web pages in the Vecta Corp site as examples of how to work with basicpage formatting techniques, tables, CSS, frames, forms and form objects, behaviors, AP elements, andmore Up until now, the process has been simple: We create a new page, add some images and text to thepage, format it with tables or divs, and then save it for viewing in the browser In a real-world scenario,however, our workflow process would be inadequate and inefficient Imagine having 500 pages within anintranet site and trying to perform day-to-day web-maintenance operations As it relates to our Vecta Corpexample, the process might resemble the following scenario:

Company Events— As a web developer, your job is to manually add and remove company events as

they're announced After the company event is on the main page, you must also create a dedicatedpage for the company event that includes pictures, directions, times, and perhaps a reservationsystem that, you guessed it, would be manually updated by you based on email reservations sent toyou

HelpDesk— The HelpDesk functions as a repository for employee hardware, software, and general

office maintenance problems In a traditional scenario, you are responsible for fielding emails fromemployees with problems and then manually posting information to the website so that the IT

department can view the problems and respond accordingly Even worse, after the IT departmentresponds and fixes the problem, they would send you an email so that you could manually remove theticket from the site

Company Directory— As the web developer, your job is to continuously add, modify, and remove

employees from the employee directory page Given today's volatile marketplace, this in itself couldbecome a daunting task!

Employee Store— As the web developer, your job also involves manually adding, modifying, and

removing products from the company's employee store But wait, there's more You are also

responsible for fielding emails from employees who are interested in a product, collecting cash, givingthe employee the product, and then manually updating a spreadsheet of inventory information

After reviewing this process, you've probably come to one conclusion: job security! As you can see, thesetasks are enough to keep you busy all day, leaving little time for your talents and skills elsewhere on thewebsite Rather than taking a design or development role as it relates to the website, you might be stuck inmaintenance mode, constantly adding, updating, and removing data from the website

This is where dynamic web pages and web applications come into play Using a web application containingnumerous dynamic web pages, you could easily streamline your workflow so that it begins to model thefollowing workflow process:

Company Events— Rather than manually adding, removing, and deleting company events, you tie

the main page of the site to a database A table within the database could contain the company eventsthat are in turn fed to an HTML table within the main page Even better, you can create a second pagethat allows Herbert in HR to add, update, and remove company events from the database using asimple administrative web page

HelpDesk— Instead of fielding emails from employees who have problems, why not create a

two-page HelpDesk system in which employees can create new HelpDesk tickets? These tickets can bestored in a table in the database A second administrative page, accessible by the IT staff, provides alist of employees with problems (fed in from the database) When the problem has been fixed, the ITstaff member selects from a drop-down menu that changes the status of the HelpDesk ticket fromOpen to Closed

Trang 2

Company Directory— Rather than manually adding, modifying, and removing employees from the

company directory, you can easily create functionality within an administrative page that allows you tocentrally add, modify, and delete employees from a database table This approach effectively

eliminates the need for manually connecting to the site, opening the HTML page, making changes, andthen re-uploading the site

Employee Store— By far the most complex part of the Vecta Corp site is the employee store.

Manually trying to add, modify, and remove products as well as collect cash, distribute products, andupdate inventories can be an extremely time-consuming process Instead, add the products to adatabase and display those products within a dynamic page Add shopping cart functionality to thepage that allows users to add and update a shopping cart on their own When it comes time to checkout, you can easily integrate payment system functionality such as PayPal to automate the process ofcollecting money from the employee

Admin— As the web developer/administrator, you'll want a centralized interface for adding,

modifying, and deleting employees Additionally, you'll want to centrally add, modify, and removeproduct information from your site This is where the administrative page comes in By creating adigital dashboard of sorts, you can easily fulfill these tasks without ever having to connect to your sitewithin Dreamweaver

After reviewing this process, you're probably starting to wonder about that job security The downside tousing dynamic web pages and databases is that you're effectively taken out of some of the processes you'vebecome accustomed to dealing with The upside is that you can now focus on building more applications foryour organization Even better, you can now focus on designing and developing the fun stuff! And thoughthe initial setup and development time is greater for our web application than for the equivalent staticpages, the benefits down the line far outweigh the time it would take to develop the application Keep inmind that Dreamweaver cuts your development time in half Because you're working with an intuitive visualeditor and not coding by hand, the time needed to create the dynamic Vecta Corp web application in

Dreamweaver will be short

The next nine chapters of the book involve building the dynamic pages for the Vecta Corp employee store

As you've seen from the bullet points describing the pages above, our web application has the potential ofbecoming a massive undertaking Since this is the case, we'll focus on the employee store page I'll outlinehow to work with databases in Dreamweaver by establishing a connection to a database, how to createbindings to the database, and how to work with the many server behaviors in Dreamweaver to build viewcatalog page, login functionality, search functionality, and more By the book's end, you should be able totake the concepts learned in the next nine chapters and build out the rest of the pages outlined in theprevious bullet points

Trang 3

Understanding what a web application is—and how different it is from a static website—is only the first step

in creating one Making decisions about server-side technologies and databases all comes down to onething: what tools are easily available?

If your company has Oracle installed and there are plenty of PHP developers available to build and supportyour web application, that's likely the way you'll go However, if you are running a small company and cost

is an issue, PHP/MySQL, ASP.NET/Access, or ColdFusion/Access might be more prudent

In the next chapter, you'll take the foundation-level concepts from this chapter to the next level You'llactually pick a server-side technology to use, learn how to install it, and then configure it to work withDreamweaver and the Vecta Corp application

Trang 4

Chapter 21 Working with Server-Side Technologies

IN THIS CHAPTER

Working with the IIS Web Server

Working with ASP

Installing and Working with ASP.NET

Installing and Working with ColdFusion

Installing and Working with PHP

Now that you've been formally introduced to the terminology that is server-side web

development—including dynamic web pages, web applications, databases, SQL, and DSNs—you're ready tomove forward into the realm of installation, set up, and configuration for the actual server-side technologyyou plan to use

By now, you should have some sort of idea about the architecture of your organization Do you have aWindows server-based operating system such as Windows Server 2000 or 2003, or are you looking at Mac

OS X Server? Are your plans to develop web applications using a development machine running Windows XPPro, Vista, or OS X and then upload the finished product to a server when you're finished? Do you want tominimize installation and configuration? Are you merely a novice who is interested in tinkering with dynamicweb page development? The answers to these questions can help you quickly determine what server-sidetechnology you plan to use with Dreamweaver It's important to note that Dreamweaver's functionality forcreating dynamic web pages is nearly identical regardless of server-side technology And because you won't

be interacting with the code all that much, picking a server-side technology shouldn't be all that difficult;they all have the same bells and whistles built in to Dreamweaver

If you haven't made a decision on the server-side technology you want to use, don't worry In this chapter,I'll demystify each of your options I'll provide an overview of the web server we'll be using (IIS) as well asdetail the nuances, installation procedures, and configuration routines (if any) for the four server-sidetechnologies that we'll cover throughout the rest of the book By the end of the chapter, you'll have a webserver up and running, a server-side technology installed and configured, and a simple dynamic pageworking!

Note

We'll be using IIS as our web server as we work through the examples in the book This server is notavailable for Mac users However, OS X ships with the Apache web server included, and it is enabledsimply by opening System Preferences, selecting the Sharing preferences pane, and clicking the

Personal Web Sharing check box You can then install MySQL and PHP, or just install MAMP/Pro

(http://www.mamp.info/) which installs MySQL and PHP all at once

Working with the Internet Information Services (IIS) Web Server

In the previous chapter, I made reference to the fact that users interact with web applications through a

Trang 5

series of carefully crafted form objects exposed to the user in the browser window The user interacts withthe form objects and then typically clicks a button, expecting to see results What we haven't discussed,however, is how those results are returned to the user.

In general, servers rely on a piece of software that is crucial in the HTTP request/response process Thispiece of software, the web server, is primarily responsible for managing various websites, FTP sites, a mailclient, and more on our server Working in conjunction with the server-side technology, the web server isalso responsible for facilitating the handoff between the client's request, the server-side technology used tohandle the request, the collection of the response from the server-side technology, and the subsequenthandoff of the response back to the client browser

Internet Information Services (IIS) is Microsoft's web server solution and is the primary focus of examplesthroughout the rest of the book IIS comes bundled with most Microsoft server-based operating systems,including Windows NT 4, Windows 2000 Pro, Server and Advanced Server, Window 2003 Server, Windows

XP Pro, Windows Vista Home Premium, Vista Business, Vista Ultimate, and Vista Enterprise

Table 21.1 outlines the major Windows operating systems and shows whether the web server comes

preinstalled with the specific operating system

Table 21.1 Major Windows Systems and IIS Support

Win 95, 98, ME, XP Home No N/A ColdFusion Only ColdFusion only

If you're not sure whether IIS is preinstalled on your computer, you can use one of these three methods tofind out:

Check for a folder called Inetpub located in the root of your system (typically C:\) drive If you have

Trang 6

that folder—as well as the wwwroot folder within it—chances are you're fine.

Select Start, Settings, Control Panel, Administrative Tools If you have a menu item for InternetServices Manager, IIS is indeed installed

Navigate to http://localhost in a browser If you see the IIS Welcome screen, IIS is installed andrunning

If IIS is there, you've got the web server installed If not, follow the steps in the next section

Installing IIS

One of the questions in application development is whether IIS has to be installed even if you are not

hosting your own web applications The answer is yes Even if you are uploading your web applications using

FTP to your web host provider, installing IIS allows you to view and configure your applications locallybefore they are ready for production

Note

As you've seen, Dreamweaver allows you to define a testing server when you define a site The sitethat you define within IIS (covered later) will become the site you specify in the testing server

category in the Site Definition dialog

IIS comes with most versions of server-based Windows operating systems, but it's not installed

automatically in all versions, which is why it might not be present on your computer If you've come to theconclusion that IIS isn't installed on your computer and you have a compatible operating system similar tothe ones listed in Table 21.1, follow these steps to install it:

1. Access the Control Panel by choosing Start, Settings, Control Panel

2. In the Control Panel, select Add or Remove Programs In Vista, the menu item is titled Programs andFeatures

3. Choose Add/Remove Windows Components In Vista, the menu item is titled Turn Windows Features

On or Off The list of components becomes visible within a few seconds

4. In the list of components, enable the Internet Information Services (IIS) option If you're using Vista,you might take the time to expand the Internet Information Services node, expand the World WideWeb Services node, expand the Application Development Features node, and then enable ASP This willguarantee that traditional ASP will work with Vista

5. Click Next (Windows may or may not prompt you to insert the original Windows software CD) to installIIS

6. After IIS is installed, close the Add or Remove Programs (Programs and Features) dialog

You can now check to see whether IIS installed correctly by performing one or all three checkpoints

highlighted in the previous section

You are now ready to begin hosting web applications Although we won't cover how to configure IIS for

Trang 7

external use, I will show you how to configure IIS to support local development of ASP, ASP.NET,

ColdFusion, and PHP applications so that you can upload them later to your external web host provider

Configuring IIS

Although little configuration needs to be done to begin working with IIS, I will use this section to introducesome basic features and functionality within IIS Reading this section will help you better troubleshootproblems that may arise later in development This section explains the following topics:

Where to keep files on the web server

Using Localhost

How to start and stop the web server

Where to Keep File on the Web Server

Now that you have IIS up and running, let's take a closer look at where the files for your Web applicationsare kept on the computer Up to this point, we've been saving our projects in the

C:\VectaCorp\<chapterfolder> directory This works fine for static web pages because we're merelytesting the functionality of the pages in the browser IIS works a bit differently, however By default, IISreads and processes the code in the file from the C:\Inetpub\wwwroot\ folder If you open this folder andcompare it to the folder tree in IIS, you'll notice some similarities Although it is not a requirement to keepapplications in this folder, it is generally considered a good repository for storing and managing your server-side applications

Note

Technically, your files don't have to be in C:\Inetpub\wwwroot\ You can also create what's called a

virtual directory A virtual directory is essentially an alias within IIS that points to a folder

somewhere else on your computer To make things easier, however, we'll work with

C:\Inetpub\wwwroot\ for the rest of the book

So that we can test how our web server works, let's create a new folder within C:\Inetpub\wwwroot andadd a simple HTML page to the new folder You can do this on your own by following these steps:

Trang 8

1. Open Windows Explorer and navigate to the root of C:\Inetpub\wwwroot.

2 Within wwwroot, create a new folder called VectaCorp.

3. Open the VectaCorp folder

4. Right-click an empty area in the folder and choose New, Text Document from the context menu

5. After you select the New Text Document option, you can rename the file Change the name, including

its extension, to index.html This action converts the text document to an HTML file.

6. Right-click the file and choose Open With, Notepad from the context menu The file will open in

8. Save the page and close Notepad

That's it! You've just created your first basic page within the context of the web server In the next section,we'll browse to the page using the default name of the web server

Using Localhost

Now that you have a new file in C:\Inetpub\wwwroot\VectaCorp, your web server has access to it Ifyou've been developing static HTML web pages for a long time, habit may drive you to open files directly inyour browser Dynamic pages can't be opened directly from the browser because your web server needs tohave a crack at the file before it is sent to your browser for display If the application server doesn't get thechance to interpret the request coded into a dynamic page, the code behind the dynamic page is neverconverted into HTML that your browser can understand

To repeat: dynamic pages can't be opened directly from the browser Instead, you'll have to open thebrowser and navigate to the web directory using the local web address for your computer, also known ashttp://localhost (or by the IP address http://127.0.0.1) More specifically, because the VectaCorpfolder is located in C:\Inetpub\wwwroot\VectaCorp on your computer, you can access it directly from thebrowser by typing in the URL http://localhost/VectaCorp Figure 21.1 shows IIS and the browser side byside so that you can visualize the point I'm trying to make

Figure 21.1 http://localhost/VectaCorp is the URL that points to the folder

C:\Inetpub\wwwroot\VectaCorp.

[View full size image]

Trang 9

In this case, the process was simple Because our default page is essentially an HTML file, nothing is reallyrequired of the web server Most of the work in this case is handled by the browser The browser parses the

literal text out of the HTML tags and presents the text Hello World to the user Because our page contained

only HTML, we could have just as easily opened the page directly in the browser, displaying the sameresults Remember though, that the web server (IIS) is the only piece of software that can access yourserver-side code (such as ASP, ASP.NET, PHP, or ColdFusion) directly For this reason, it's a good idea thatyou get into the habit of accessing your dynamic pages directly from

http://localhost/<yourfoldername> This is how it will be done throughout the rest of the book manuallyand via Dreamweaver

Stopping and Starting IIS

With IIS now up and running, let's now look at how you can start, stop, and restart IIS if the need arises.For the most part, you'll always want to have IIS running except when you're using certain programs locallythat open ports allowing intruders to compromise the security of your computer Some programs, such aspeer-to-peer (P2P) file-sharing programs, automatically stop IIS when it launches because of potentialsecurity vulnerabilities

If you want to stop IIS when it's not being used, follow these steps:

1. Open IIS by choosing Start, Settings, Control Panel, Administrative Tools, Internet Information

Services (Now would be a good time to create a shortcut on the desktop for this application.)

2. With IIS open, select Default Web Site The Start, Stop, and Restart icons become visible

3. Click the Stop option shown in Figure 21.2 The web server is now stopped

Figure 21.2 Select Stop to stop IIS.

Trang 10

4. To start IIS again, all you need to do is click the Start icon IIS will start again.

If you want to restart IIS, you can perform the steps just listed or you can make life easier on yourself byentering a simple command in the Run dialog To do this, follow these steps:

Trang 11

1. Select Start and then choose Run The Run dialog appears.

2 Type iisreset into the text box and click OK The Command window appears and runs through the

reset routine shown on Figure 21.3

Figure 21.3 The Command window runs a script that restarts IIS.

[View full size image]

Trang 12

Chapter 21 Working with Server-Side Technologies

IN THIS CHAPTER

Working with the IIS Web Server

Working with ASP

Installing and Working with ASP.NET

Installing and Working with ColdFusion

Installing and Working with PHP

Now that you've been formally introduced to the terminology that is server-side web

development—including dynamic web pages, web applications, databases, SQL, and DSNs—you're ready tomove forward into the realm of installation, set up, and configuration for the actual server-side technologyyou plan to use

By now, you should have some sort of idea about the architecture of your organization Do you have aWindows server-based operating system such as Windows Server 2000 or 2003, or are you looking at Mac

OS X Server? Are your plans to develop web applications using a development machine running Windows XPPro, Vista, or OS X and then upload the finished product to a server when you're finished? Do you want tominimize installation and configuration? Are you merely a novice who is interested in tinkering with dynamicweb page development? The answers to these questions can help you quickly determine what server-sidetechnology you plan to use with Dreamweaver It's important to note that Dreamweaver's functionality forcreating dynamic web pages is nearly identical regardless of server-side technology And because you won't

be interacting with the code all that much, picking a server-side technology shouldn't be all that difficult;they all have the same bells and whistles built in to Dreamweaver

If you haven't made a decision on the server-side technology you want to use, don't worry In this chapter,I'll demystify each of your options I'll provide an overview of the web server we'll be using (IIS) as well asdetail the nuances, installation procedures, and configuration routines (if any) for the four server-sidetechnologies that we'll cover throughout the rest of the book By the end of the chapter, you'll have a webserver up and running, a server-side technology installed and configured, and a simple dynamic pageworking!

Note

We'll be using IIS as our web server as we work through the examples in the book This server is notavailable for Mac users However, OS X ships with the Apache web server included, and it is enabledsimply by opening System Preferences, selecting the Sharing preferences pane, and clicking the

Personal Web Sharing check box You can then install MySQL and PHP, or just install MAMP/Pro

(http://www.mamp.info/) which installs MySQL and PHP all at once

Working with the Internet Information Services (IIS) Web Server

In the previous chapter, I made reference to the fact that users interact with web applications through a

Trang 13

series of carefully crafted form objects exposed to the user in the browser window The user interacts withthe form objects and then typically clicks a button, expecting to see results What we haven't discussed,however, is how those results are returned to the user.

In general, servers rely on a piece of software that is crucial in the HTTP request/response process Thispiece of software, the web server, is primarily responsible for managing various websites, FTP sites, a mailclient, and more on our server Working in conjunction with the server-side technology, the web server isalso responsible for facilitating the handoff between the client's request, the server-side technology used tohandle the request, the collection of the response from the server-side technology, and the subsequenthandoff of the response back to the client browser

Internet Information Services (IIS) is Microsoft's web server solution and is the primary focus of examplesthroughout the rest of the book IIS comes bundled with most Microsoft server-based operating systems,including Windows NT 4, Windows 2000 Pro, Server and Advanced Server, Window 2003 Server, Windows

XP Pro, Windows Vista Home Premium, Vista Business, Vista Ultimate, and Vista Enterprise

Table 21.1 outlines the major Windows operating systems and shows whether the web server comes

preinstalled with the specific operating system

Table 21.1 Major Windows Systems and IIS Support

Win 95, 98, ME, XP Home No N/A ColdFusion Only ColdFusion only

If you're not sure whether IIS is preinstalled on your computer, you can use one of these three methods tofind out:

Check for a folder called Inetpub located in the root of your system (typically C:\) drive If you have

Trang 14

that folder—as well as the wwwroot folder within it—chances are you're fine.

Select Start, Settings, Control Panel, Administrative Tools If you have a menu item for InternetServices Manager, IIS is indeed installed

Navigate to http://localhost in a browser If you see the IIS Welcome screen, IIS is installed andrunning

If IIS is there, you've got the web server installed If not, follow the steps in the next section

Installing IIS

One of the questions in application development is whether IIS has to be installed even if you are not

hosting your own web applications The answer is yes Even if you are uploading your web applications using

FTP to your web host provider, installing IIS allows you to view and configure your applications locallybefore they are ready for production

Note

As you've seen, Dreamweaver allows you to define a testing server when you define a site The sitethat you define within IIS (covered later) will become the site you specify in the testing server

category in the Site Definition dialog

IIS comes with most versions of server-based Windows operating systems, but it's not installed

automatically in all versions, which is why it might not be present on your computer If you've come to theconclusion that IIS isn't installed on your computer and you have a compatible operating system similar tothe ones listed in Table 21.1, follow these steps to install it:

1. Access the Control Panel by choosing Start, Settings, Control Panel

2. In the Control Panel, select Add or Remove Programs In Vista, the menu item is titled Programs andFeatures

3. Choose Add/Remove Windows Components In Vista, the menu item is titled Turn Windows Features

On or Off The list of components becomes visible within a few seconds

4. In the list of components, enable the Internet Information Services (IIS) option If you're using Vista,you might take the time to expand the Internet Information Services node, expand the World WideWeb Services node, expand the Application Development Features node, and then enable ASP This willguarantee that traditional ASP will work with Vista

5. Click Next (Windows may or may not prompt you to insert the original Windows software CD) to installIIS

6. After IIS is installed, close the Add or Remove Programs (Programs and Features) dialog

You can now check to see whether IIS installed correctly by performing one or all three checkpoints

highlighted in the previous section

You are now ready to begin hosting web applications Although we won't cover how to configure IIS for

Trang 15

external use, I will show you how to configure IIS to support local development of ASP, ASP.NET,

ColdFusion, and PHP applications so that you can upload them later to your external web host provider

Configuring IIS

Although little configuration needs to be done to begin working with IIS, I will use this section to introducesome basic features and functionality within IIS Reading this section will help you better troubleshootproblems that may arise later in development This section explains the following topics:

Where to keep files on the web server

Using Localhost

How to start and stop the web server

Where to Keep File on the Web Server

Now that you have IIS up and running, let's take a closer look at where the files for your Web applicationsare kept on the computer Up to this point, we've been saving our projects in the

C:\VectaCorp\<chapterfolder> directory This works fine for static web pages because we're merelytesting the functionality of the pages in the browser IIS works a bit differently, however By default, IISreads and processes the code in the file from the C:\Inetpub\wwwroot\ folder If you open this folder andcompare it to the folder tree in IIS, you'll notice some similarities Although it is not a requirement to keepapplications in this folder, it is generally considered a good repository for storing and managing your server-side applications

Note

Technically, your files don't have to be in C:\Inetpub\wwwroot\ You can also create what's called a

virtual directory A virtual directory is essentially an alias within IIS that points to a folder

somewhere else on your computer To make things easier, however, we'll work with

C:\Inetpub\wwwroot\ for the rest of the book

So that we can test how our web server works, let's create a new folder within C:\Inetpub\wwwroot andadd a simple HTML page to the new folder You can do this on your own by following these steps:

Trang 16

1. Open Windows Explorer and navigate to the root of C:\Inetpub\wwwroot.

2 Within wwwroot, create a new folder called VectaCorp.

3. Open the VectaCorp folder

4. Right-click an empty area in the folder and choose New, Text Document from the context menu

5. After you select the New Text Document option, you can rename the file Change the name, including

its extension, to index.html This action converts the text document to an HTML file.

6. Right-click the file and choose Open With, Notepad from the context menu The file will open in

8. Save the page and close Notepad

That's it! You've just created your first basic page within the context of the web server In the next section,we'll browse to the page using the default name of the web server

Using Localhost

Now that you have a new file in C:\Inetpub\wwwroot\VectaCorp, your web server has access to it Ifyou've been developing static HTML web pages for a long time, habit may drive you to open files directly inyour browser Dynamic pages can't be opened directly from the browser because your web server needs tohave a crack at the file before it is sent to your browser for display If the application server doesn't get thechance to interpret the request coded into a dynamic page, the code behind the dynamic page is neverconverted into HTML that your browser can understand

To repeat: dynamic pages can't be opened directly from the browser Instead, you'll have to open thebrowser and navigate to the web directory using the local web address for your computer, also known ashttp://localhost (or by the IP address http://127.0.0.1) More specifically, because the VectaCorpfolder is located in C:\Inetpub\wwwroot\VectaCorp on your computer, you can access it directly from thebrowser by typing in the URL http://localhost/VectaCorp Figure 21.1 shows IIS and the browser side byside so that you can visualize the point I'm trying to make

Figure 21.1 http://localhost/VectaCorp is the URL that points to the folder

C:\Inetpub\wwwroot\VectaCorp.

[View full size image]

Trang 17

In this case, the process was simple Because our default page is essentially an HTML file, nothing is reallyrequired of the web server Most of the work in this case is handled by the browser The browser parses the

literal text out of the HTML tags and presents the text Hello World to the user Because our page contained

only HTML, we could have just as easily opened the page directly in the browser, displaying the sameresults Remember though, that the web server (IIS) is the only piece of software that can access yourserver-side code (such as ASP, ASP.NET, PHP, or ColdFusion) directly For this reason, it's a good idea thatyou get into the habit of accessing your dynamic pages directly from

http://localhost/<yourfoldername> This is how it will be done throughout the rest of the book manuallyand via Dreamweaver

Stopping and Starting IIS

With IIS now up and running, let's now look at how you can start, stop, and restart IIS if the need arises.For the most part, you'll always want to have IIS running except when you're using certain programs locallythat open ports allowing intruders to compromise the security of your computer Some programs, such aspeer-to-peer (P2P) file-sharing programs, automatically stop IIS when it launches because of potentialsecurity vulnerabilities

If you want to stop IIS when it's not being used, follow these steps:

1. Open IIS by choosing Start, Settings, Control Panel, Administrative Tools, Internet Information

Services (Now would be a good time to create a shortcut on the desktop for this application.)

2. With IIS open, select Default Web Site The Start, Stop, and Restart icons become visible

3. Click the Stop option shown in Figure 21.2 The web server is now stopped

Figure 21.2 Select Stop to stop IIS.

Trang 18

4. To start IIS again, all you need to do is click the Start icon IIS will start again.

If you want to restart IIS, you can perform the steps just listed or you can make life easier on yourself byentering a simple command in the Run dialog To do this, follow these steps:

Trang 19

1. Select Start and then choose Run The Run dialog appears.

2 Type iisreset into the text box and click OK The Command window appears and runs through the

reset routine shown on Figure 21.3

Figure 21.3 The Command window runs a script that restarts IIS.

[View full size image]

Trang 20

Working with ASP

Quite possibly the simplest technology to use in conjunction with Dreamweaver dynamic web page

development is ASP ASP, or Active Server Pages, is a Microsoft-developed web-scripting language that tookthe web development world by storm when it was introduced in the mid 1990s ASP is easy to understandand easy to use—and setup is a breeze because the required files are preinstalled on virtually all Windowsservers

Like many other server-side technologies, ASP enables you to embed special instructions in HTML pages thatcan do a variety of tasks, such as connect to a database, perform looping instructions, conditionally test forcertain values, send emails, read from and write to the file system, and more Because ASP runs natively onMicrosoft's IIS web server, installing ASP generally means installing IIS If IIS is up and running, chancesare, so is ASP It's no wonder that the majority of users who create dynamic web pages in Dreamweaver stilluse traditional ASP as their server-side technology of choice; if you have IIS installed (which most peoplewho are building dynamic web pages do), there's little or no setup and nothing to install

Creating a Simple ASP Page

Let's walk through the process of creating a simple ASP page Not only will this process help familiarize youwith the technology, but you'll also get a decent understanding of how IIS handles the processing of adynamic ASP page To create a simple ASP page, follow these steps:

1. Create a new folder in C:\Inetpub\wwwroot called VectaCorpASP.

2. Open Notepad (we'll get to Dreamweaver later)

3. In the document, add the following code:

<h1>This is plain text</h1>

<h1><%= "This is ASP writing text to the browser dynamically" %></h1>

To test your work, open the browser and type the http://localhost/VectaCorpASP/sample.asp URL into

the address bar As you can see from Figure 21.4, two lines of text appear in the browser

Trang 21

Figure 21.4 Two lines of text appear in the browser.

[View full size image]

Although this result may not seem all that awe inspiring, think again: You've just created your first dynamicweb page using ASP Look at the code again and see if you can pick apart the dynamic portions of the page.For the most part, 8 of the 9 lines of code on the page are plain old HTML that IIS does nothing with Itsimply lets the browser parse the HTML tags and presents the text inside them to the user Line 7, however,works a bit differently:

<h1><%= "This is ASP writing text to the browser dynamically" %></h1>

In this case, we use what's called a code render block to dynamically display the text This is ASP writing text

to the browser dynamically within a <h1> HTML tag IIS, recognizing that this code render block exists,intercepts the request and calls for help from the asp.dll located in the C:\Windows\system32\inetsrv folder

The asp.dll processes the request and takes the code render block to mean "Print out the text This is ASP writing text to the browser dynamically" on the page This response is sent back to IIS and ultimately back

to the browser, formatted using the <h1> tag Although the process may seem complex, it happens so fastthat a user rarely knows that a dynamic page is even being used

See how easy that was? In this example, we manually wrote ASP code The beauty in using Dreamweaver isthat you don't have to Dreamweaver writes all the necessary code for you More on this later For now, let'sfocus on getting our project configured so that we can use ASP to create dynamic VectaCorp pages

Configuring VectaCorp to Run Under ASP

Up to this point, we've been working primarily from C:\VectaCorp\<chapterfolder> From now on, we'llwork from C:\Inetpub\wwwroot\VectaCorpASP (assuming that you're using ASP) Because this is the case,

we need to reconfigure the site definition to point to the new folder we've created Furthermore, we need toconfigure the Testing Server category in the Site Definition window to provide Dreamweaver with

information specific to the technology you plan to use for the defined site To configure VectaCorp to rununder ASP, follow these steps:

1. If you haven't downloaded the files for this chapter, do so now Open the folder for Chapter 21, copythe contents of the folder, and paste them into the newly created VectaCorpASP folder in

C:\Inetpub\wwwroot Now you have all the images, a template, and an index.asp page to get youstarted Specifically, after you've copied the files over, you should have Images, a Template folder thatincludes the main template for the site, a CSS file, an index.asp page, and the sample.asp page thatyou built in the previous section

Trang 22

2. Open Dreamweaver if you haven't already done so and choose the Manage Sites option from the Sitemenu.

3. Select the existing VectaCorp site from the list and click Edit The Site Definition for VectaCorp dialogappears

4 In the Site Name text box, rename the site from VectaCorp to VectaCorpASP.

5. Browse to the C:\Inetpub\wwwroot\VectaCorpASP\ folder within the Local Root Folder field Leaveeverything else as is The result is shown in Figure 21.5

Figure 21.5 Rename the site definition and set the local root folder to point to the

C:\Inetpub\wwwroot\VectaCorpASP\ folder.

[View full size image]

6. Switch to the Testing Server category

7. Select the ASP VBScript option from the Server model menu

8. Choose the Local/Network option from the Access menu New properties become available that allowyou to configure the location of the remote folder as well as the URL prefix for the remote folder

Trang 23

9. Browse to the same C:\Inetpub\wwwroot\VectaCorpASP\ path in the Remote Folder text box In mostcases, this value is prepopulated when you select the Local/Network option from the Access menu.

Note

When working with web applications, the ideal scenario is that you'll have a developmentmachine, a production machine (server), and a testing server Realistically, not everyonecan afford another server just for testing purposes Most of us will rely on the

development machine to function as a testing server as well For this reason, we'll leavethe testing server path as is If you do have a dedicated testing server, you'd probablystill choose the Local/Network option from the Access tab; however, rather than findingthe machine locally, you'd browse to it on the network

10 Now enter the URL to our VectaCorp site in the URL Prefix text box This value should read

http://localhost/vectacorpasp/ Remember that localhost, like every other domain name

(yahoo.com, google.com, and so on) is a URL that is accessible from a browser Rather than accessingthe site from a server miles away, the browser knows that localhost (and the IP address 127.0.0.1associated with it) is the URL for the local instance of IIS (your computer) It doesn't have to look toofar for your files When you finish configuring this screen, the result will look similar to Figure 21.6

Figure 21.6 Configure the Testing Server category.

[View full size image]

Trang 24

11 Click OK to close the Site Definition for VectaCorpASP window.

12 Click Done to close the Manage Sites dialog.

You're now ready to begin building dynamic VectaCorp pages using Dreamweaver and ASP!

Using ASP in Dreamweaver

Depending on the server technology you decide to use, features (as they relate to the specific server

technology) within the Dreamweaver interface will change For the most part, however, you can bank on thefact that the following features will always be available in Dreamweaver when you're working with anyserver-side technology:

The Insert bar— A visual representation of objects available in the Insert menu, the Data category in

the Insert bar (shown in Figure 21.7), allows you to visually insert various types of dynamic objectsonto your page

Figure 21.7 Use the Insert bar as a visual tool for inserting dynamic objects on your page.

[View full size image]

Trang 25

The Insert menu— Use the Data Objects and ASP Objects submenus in the Insert menu to insert

both generic data objects as well as ASP-specific objects

The Application panel— Split into four tabs—Databases, Bindings, Server Behaviors, and

Components—the Application panel provides the means for connecting to and accessing databasedata, binding that data to elements on the page, and accessing the various application objects thatwere also available from the Insert menu When working with dynamic pages in Dreamweaver, youshould always have this panel open The Server Behaviors tab of the panel is shown with more detail

in Figure 21.8

Figure 21.8 Use the Application panel when working with databases, binding database data

to your dynamic pages, and working with various application objects.

Note

Although the Components panel is available as an option, it is inactive under the ASP servermodel It is available only under the ASP.NET and ColdFusion server models

The Tag Chooser— If you want to make fine-tuned changes in your ASP code, you can always choose

specific tags from the Tag Chooser, shown in Figure 21.9 When you choose an option from the TagChooser (available by choosing Insert, Tag), the Properties dialog for the particular tag opens,

allowing you to further customize attributes of the tag

Ngày đăng: 01/07/2014, 19:20

TỪ KHÓA LIÊN QUAN