Three powerful features implemented with ASP

Source: Internet
Author: User
Tags case statement command line contains execution iis include variable root directory

Add a spelling checker to a Web site

Many developers have raised the issue of "How to spell Check user input", and this article provides a useful way to discuss how to use the Xde spelling checker, which can be used as both a spell inspector and a dictionary. One good news about this component is that it can be used on the server side or as a Java applet. But one thing, these conveniences are not free, it costs about 100 dollars. However, the component provides a 30-day free use evaluation version, so before you really decide to buy, you can carefully test to see if it meets your needs.

First, visit the http://mirrordns.com/download/site, enter some information (name, email, etc.) and download and install the component. Next, download the "Quick Spell Check full Install" project from the many XDE components available for download. When the download is complete, install it. Before the Setup program is complete, a registration menu appears, and simply select the default selection "Evaluation Period".


Note that the current program is still a beta version. If you do not wish to have a potential error, I propose to wait until the first official version comes out and then download the test. I have found some errors in the existing version. Keep in mind: This is a beta version, not applied on the official site.


Next, prepare to register the registration component. Now decide if you want to include the Dictionary and dictionary features of Word 97, if necessary, install Word 97 or Word 2000 on the Web server, and then refer to the Http://mirrordns.com/spellchecker/server_ Installation.htm's instructions perform a special set of commands. If you do not want to use the entire Word 97 dictionary, just like registering other components:

Copy DLL file SpellCheckServer.dll to Windows system or System32 directory

Registering components with regsvr32: regsvr32 spellcheckserver.dll

Now that you have installed the components, you can use them in your ASP code. To create an example that uses the spelling checker object, simply write the following code:


Set Objspellcheck = Server.CreateObject ("Spellcheck.clschecker")

As I mentioned earlier, this component provides spelling checker and dictionary functionality. First, let's look at how to return a series of synonyms for a given word. This uses the Lookupsynonym method, which requires a parameter, which is a word that needs to look for synonyms. After execution, the spelling checker objects collect related words to the collection object Synonymwords. Execute the following code  prayer 癚 Uick "all synonyms for the word:


<%


Dim objspellchecker, iloop

' Create An instance of the ' S Pellchecker

Set objspellcheck = Server.CreateObject ("Spellcheck.clschecker")

Objspellchecker.usemsword = False ' We ' re not using MSWord

objspellchecker.lookupsynonym ' Quick ' Lookup the Synon Ym for "quick"

' Loop through the returned words:

Response.Write ' The following synonyms for ' quick ' exist: "

for iloop = 1 to Objspellchecker.synonymwords (" Quick "). Suggestedwords.count

Response.Write objspellchecker.synonymwords ("Quick"). Suggestedwords (iloop). Word

Response.Write "

Next


%>

Performing spell checking on the server side is very compact for code structure , but as I saw, to play a powerful function, you must rely on the Java applet form of the spelling checker. The following will focus on how to apply this approach, see http://mirrordns.com/spellchecker/for a method of using components on the server side.

In order to use Java applets, you need to copy the. class file under the installation directory to a Web accessible directory. For example, move the file to the/spellcheck directory here. Then, create a form that contains a text box or text field that you want to check for spelling.

< html>

< body>

< FORM name= "Frmspellcheckexample" >

< textarea name= "Javatextarea" rows= "8" cols= "M" >< p>

< INPUT type= "button" value= "Start Spell Check" >

Next, use the applet tag to refer to the Java applet:

< applet codebase = "/spellcheck/" code= "Spellcheck.class"

height= "1" name= "spellcheck" width= "1"

alt= "Applet not Displayed" >

< param name= "foreground" value= "FFFFFF" >

< param name= "background" value= "008080" >

< param name= "label" value= "This string is passed from the HTML host." >


Note:The codebase parameter in the applet tag points to the directory where the. class file resides.

Finally, use a section of JavaScript code on the client to assemble the applet parameters:

< script language= "JavaScript" >

function SpellCheck () {

Document.spellcheck.ptexttocheck =

Document.frmSpellCheckExample.JavaTextArea.value;

DOCUMENT.SPELLCHECK.DODLG ();

if (document.spellcheck.fixedtext!= "") {

Document.frmSpellCheckExample.JavaTextArea.value =

Document.spellcheck.fixedtext;

}

}

It's done! If you want to learn more about how to use this component and Java applets, be sure to take a look at the places below: http://mirrordns.com/spellchecker/.

   dynamically building barcodes on the Web

This article discusses how to dynamically create barcodes on the web based on database fields, this is useful in situations where the user enters the information into the system and then displays a summary page "This is what you entered", this page can be printed, and in the day poppy-tip maps Guo   tong?


The key to achieving this is how to translate values such as "ABC" into barcodes. Here we use "Code 39", for more information on it, see the definition. I want to display the resulting barcode on a Web page so that the user can print the page that contains the barcode, and then use it in the processing of the graphics system. Many users have the "Code 39" font installed in the system, so I can change it on the page, but I don't want to rely on them. I want to build on the page and be independent of the browser and the computer.


My solution is to create a GIF graphics file for each character supported in Code39. I use the Microsoft Paint software to create a text box with a Code39 font size, and then build a graphic for each character. Next, use Microsoft Image composer to convert them to GIF format. Finally, use the scanning software to check these characters to see if they can be interpreted correctly. Below, you will see barcodes for a, B, C, and asterisk (*):


Code for A


Code for B


Code for C


Code for Asterisk


Then, in order to depict the barcode of the value in the database in the ASP page, simply traverse each character in the Barcodetext variable string, and then build the < IMG src= "..." > tag to replace the character with the corresponding barcode graphics file. This is very simple and does not require a font file to be installed on the client. The relevant code is as follows:


' Code barcodes require an asterisk as the start and stop characters

Response.Write "< IMG src=" "http://www.webjx.com/htmldata/2005-12-11/http://www.webjx.com/htmldata/2005-12-11/ Asterisk.gif "" Width= "" "" "Height=" "" > "

For x = 1 to Len (Trim (RST ("Barcodetext"))

Response.Write "< IMG src=" "" & Mid (RST ("Barcodetext"), x,1) & _

". gif" "width=" "," "height=" "," ">"

Next


' Code barcodes require an asterisk as the start and stop characters

Response.Write "< IMG src=" "http://www.webjx.com/htmldata/2005-12-11/http://www.webjx.com/htmldata/2005-12-11/ Asterisk.gif "" Width= "" "" "Height=" "" > "



If the value that is barcodetext in the recordset's current record is "ABC", then the result of the HTML after executing the above code is:


< IMG src= "Http://www.webjx.com/htmldata/2005-12-11/http://www.webjx.com/htmldata/2005-12-11/asterisk.gif" Width= "height=" >

< IMG src= "http://www.webjx.com/htmldata/2005-12-11/A.gif" width= "height=" >

< IMG src= "http://www.webjx.com/htmldata/2005-12-11/B.gif" width= "height=" >

< IMG src= "http://www.webjx.com/htmldata/2005-12-11/C.gif" width= "height=" >

< IMG src= "Http://www.webjx.com/htmldata/2005-12-11/http://www.webjx.com/htmldata/2005-12-11/asterisk.gif" Width= "height=" >



The following graphic is then displayed:


Now that the page is printed, it can be tracked by the barcode scanner.


There are 2 things to note about barcodes: Not all barcodes can support all character sets. Code39 is a very good and simple one. It has a variable length that supports all uppercase letters, numbers, asterisks, and 7 special characters. For each character, it uses a consistent 5-line (2-width 3-narrow) 4-empty (meaning gap, 1-width 3-narrow) Form. Additional character sets support more, using different decoding schemes. Make sure that you have a GIF graphic file for each character, and that you can modify the width and height of the graphic to display slightly larger or slightly smaller barcodes on the page.


In addition, if you encounter special characters, the traversal loop code above will not work because the GIF file cannot be named +.gif. At this point, write a function that accepts character ASCII values, and then use the case statement to return the string equivalent to the filename. If the value of the database field is integral or contains only characters or numbers, the traversal code above is good!


The method described above is not very complicated, but in some ways it is simple and easy to use.

How do I hide a page to avoid being searched

The search engines that we navigate on the Web use small programs---such as the ' robots ', ' bots ', ' crawlers ' and ' spiders '---We know to index the page. However, when developing a site, especially when using ASP for development, it is useful to prevent pages from being indexed. When these search engines are reviewing their scenarios for dynamically indexing the Web pages they create, such as the ASP page, this article will help you learn some important tips to avoid robots tracking pages that you don't want to be indexed by.

Why does this have something to do with you?

For example, now you've visited XYZ company's web site and searched for ' XYZ Corp. ' with your familiar search engine. If you find that your admin page is also in the relevant linked table, you will be a little worried. If you have an ecommerce site, you will not be willing to get the URL of the last page of the order portion of this site before the user ends the previous page. Not only does the network manager not want to happen. It is also annoying for users that some pages are not functioning properly, either because they do not have the appropriate permissions, or because they do not access the page in the order set. This is not conducive to the reputation of your site. This is also related to the operators of the commercial search engines themselves. Because they want to provide accurate links to improve the service.

So how do you prevent these programs from indexing certain pages of your site? There are two ways to choose between including a file named robots.txt in the root directory, or using the < META > tag.

Contains a robots.txt file

As early as 1994, an automated mailing list presented a joint agreement to prevent a robotic drag-and-drop site. But this is not a formal standard, it does not provide the guarantee of execution, but it is used by many robot authors.

Creating a robots.txt file is very simple, and it shows the robot behavior standards that administrators want. Note that the file name must be in lowercase letters and must be placed in the root folder of the site, such as Http://xyzcorp/robots.txt, so that a file can bring out all the details of the entire site.

what's in a robots.txt file?

Each robots.txt file contains one or more records. A record consists of a robot user agent string that you are willing to follow and instructions to apply to it. Don't worry about all the robot user agent strings you need to know to roam the web, because you can use wildcard * To apply all the robots. The following is an example of a record:


User-agent: *

Disallow:/xyzfinances.asp

Disallow:/admin

Disallow:/news/update.asp


In addition to the user agent string/wildcard character, you only need to include a disallow command. This simple example shows all the possibilities you will need. It indicates that no user agent string can enter xyzfinances.asp, which is represented by this line:

Disallow:/xyzfinances.asp

Alternatively, the user agent string cannot enter the administrative folder and all of the folders below it:

Disallow:/admin

Or a update.asp file in a news folder, if all the other content in the News folder can be indexed.

The name of the user agent string you would like to include in a record. Also in any robots.txt file, you can include as many records as you like (as long as you separate the records with one or more blank lines).

Each individual record can provide different instructions for one or more robots. However, it is advisable to add a wildcard rule to an engine that is not named with the user agent string. The most popular option is to maintain a scheme that represents a single record and a wildcard character that represents a user agent string. A list of 196 user agents is available for reference

Http://info.webcrawler.com/mak/projects/robots/robots.html.

It is generally believed that robots should ignore case and version numbers. Keep in mind that this is the opinion of the robots in most business search engines, because you don't want to use useless pages to upset users. However, although you do not have to consider the case at the command line, you must be sure to type the URL correctly. Although Windows NT does not care about the capitalization of file names and pathname, not all platforms are.

The only other things you want to include are annotations, which use the Unix Bourne shell protocol, such as the # notation for whitespace before the hash symbol, and the rest of the line that can be ignored. If a line contains only one annotation, it can be completely ignored, although it does not function as a blank line between records.

Now look at the two final examples.

Example 1


# Don ' t come to this site

User-agent: *

Disallow:/# disallows anything


Example 2


# robots.txt for XYZCorp

# Webmaster:john Doe Contact JohnD@xyzcorp.com

User-agent: * Applies to all robots except next record

Disallow:/store/order/# No robot should visit any URLs starting with

/store/order/

Disallow:/admin/# Disallow any pages in the Admin folder

Disallow:/world_domination.asp # Disallow World_domination.asp


Well, that's all about the Robot.txt file.

The following describes how to use the < META > tag.

Use a < META > robot tag

Again, you cannot guarantee that a robot will fully comply with the instructions in the < META > tag, but it is still very effective for commercial search engines. < META > tags must be included in the < head > section of a file. The principle of their work is to tell robot whether a page with this tag can be indexed, and whether it can follow any links on the page or in the folders below it.

again, the syntax is very simple. The first example is:

< META name= "robots" content= "Noindex" >


This line of code tells robot not to index this page.

Next Example:

< META name= "robots" content= "nofollow" >

Allows robot to index this page, but stipulates that it cannot follow any links on this page. If you want to disable both, you can use:

< META name= "robots" content= "Noindex, nofollow" >

This means that you do not index this page, and do not follow any links on this page. However, there is a simpler way:

< META name= "robots" content= "None" >

Or do not index the page, or follow any links on this page.

Unfortunately, if you have a file named admin.asp linked to update.asp, use < META > in admin.asp

tags to prevent robot from indexing admin.asp or update.asp, but forgetting to link to a different update.asp

The same process is done on the page, so robot can still reach update.asp through the second page of the < META > tag.

In addition, you can also use the value index. However, since they are ignored as defaults, this is not necessary and does not make sense.

If you are using IIS, you should always use a custom HTTP header file to execute the < META > Tagging method. Theoretically, a robot response to the < META > tag created in this way should be exactly the same, as it seems:

< META http-equiv= "robots" content= "Noindex" >

Theoretically, we can now use the custom headers created by IIS for all files or virtual paths in all folders or folders. But so far, the test of this method has not been successful. None of these methods can fully guarantee that your page will be hidden. Indeed, if someone intentionally writes a robot to find your private page, they become a pointer to the page the author wants to protect. However, for the purpose of preventing a commercial Site index page, these methods still work and only make sense in this regard.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.