Use FileSystem components to implement local specific prints in web applications
Source: ChinaASP
1. Introduction With the rapid development of the Internet, many companies have developed Web-based business application systems. In general, both web-based business applications use three or three-layer structures, the front desk, the client is a normal web browser, the intermediate business logic application layer is stored on the web server, and the service component on the web server is accessed. Background database. For the internet of the business system and the Internet, the web server and database system are hosted in the IDC (Internet Data Center), which requires the extraction of service data from the host on the IDC server to print output. In the case where the client browser can only print a simple HTML page, it is required to be more powerful and flexible; through the related technique to expand the browser function, you can complete more complex data printing tasks, such as Receive, payment, etc. When the author used to develop education management software for a network education company, the author uses the FileSystem component to implement the functions of the three-game payment voucher and admission tickets. 2, FileSystem Component Introduction FileSystem Components is actually an ActiveX control, which exists in the Windows platform (regardless of Win98, Win2000, or NT environment contains this component.), CLSID: 0D43FE01-11CF-8940-00A0C905428. Familiar with the ASP programming can use the FileSystem component, in general, the components are used in the server side to access and control text files, folders and drives. Object instances of FileSystem components can be created by two ways: 1. Use ASP's built-in object Server method server.createObject to create an instance of server-side objects. 2. Use the VBScript script function createObject to create an instance of the client object (or the method can be used on the server, but sometimes it will be wrong, generally not used;). FileSystem components operate on text files The following methods: CreateTextFile (filename, [overwrite if exissrs], [unicode / ascii]) // Create text file opentextFile (filename, [input / output mode], [create if not exists], [Format]) // Open text file CopyFile (filename1, filename2, [overwrite]) // Copy text file movefile (filename1, filename2) // Mobile text file deletefile (filename) // Delete text file getfile (filename) // Getting text file fileexists (filename) // Determines if the text file exists that the FileSystem component is similar to the folder and drive, and the text file is similar. In fact, the FileSystem component can also be used in the client, using the second method of creating a FileSystem component object instance, you can use this component to access and control the text files, folders and drives of the client system. Because the Microsoft platform has a FileSystem component, you don't need to download from the remote server for the client of the Microsoft platform. It will be installed and registered in installing the operating system; and the client for other platforms must install the plugin and download the FileSystem component. .
3. Implementation mechanism for local specific printing utilizes FileSystem components to implement local-specific printing procedures as shown in the figure: 1, the client sends a data request to the web server; The end browser sends back the HTML page; There is no difference between the first two steps and the general web application, it is necessary to explain the third step: first use the VBScript script function createObject to create an instance of the FileSystem component object; then call the examplextExtFile method of the text file, put the print port LPT1 or The LPT2 is used as a file name parameter and sets the overwritable file parameters to True to establish a connection with the printer; the write text method of the printer text file instance is written to the printer outputs the content.