-By Elaya Manickam Narayanan.
We all must have used the "Scripting.FileSystemObject" progid to create text files. But only a few know that it can be used for writing all kinds of files. For example, you can create html files using the filesystemobject. And why not, you can even write ASP files using an asp file! That's right! An ASP Code generator.
Here's the complete code of how this can be done: Just copy and paste the following code into an asp file. Invoke your browser and request the asp file. Eureka! The file generates its own asp file (generatedasp.asp) and submits itself. For any queries regarding this article mail me at elayamanickam@indya.com. Happy programming!
<%
'Author Name : Elaya Manickam Narayanan 'Purpose : Generates as output an .asp file
'Create the ASP file 'Variables Declaration Dim fso Dim i 'Create Object for the ASP File Set fso = Server.CreateObject("Scripting.FileSystemObject") 'Create the asp file Set FileSys = fso.CreateTextFile(Server.mappath("generatedasp.asp"),true) 'Procedure to write the asp file Call WriteASP() 'Close the file FileSys.Close 'Release the reference Set FileSys = Nothing
'Procedure for the body of the Generated asp file Sub WriteASP() FileSys.WriteLine("<%") FileSys.WriteLine("'******This file was generated by vbscript******") FileSys.WriteLine("Response.write ""You logged in as:"" & Request(""login"")") FileSys.WriteLine("Response.Write ""<BR>""") FileSys.WriteLine("Response.write ""Your password is:"" & Request(""password"")") 'In the following line '%' and '>' are intentionally seperated becos it 'generates an error if they are given together. FileSys.WriteLine("%" & ">") End Sub %> <html> <head> </head> <body> <form name = "form1" action = "Generatedasp.asp" method = "post"> <table align = "center" border = "1"> <tr> <td> Login </td> <td> <input type ="text" name ="login" maxlength = 12> </td> </tr> <tr> <td> Password </td> <td> <input type="password" name ="password" maxlength = 12> </td> </tr> <tr> <td> </td> <td> <input type ="Submit" value ="Submit"> </td> </tr> </table> </form> </body> </html>
|
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles More By aspfree developerWorks - FREE Tools! | Visit IBM developerWorks to download a free trial of the Rational Host Access Transformation Services (HATS) Toolkit. The HATS toolkit provides a set of plug-ins for the IBM Rational Software Delivery Platform to help you easily extend your legacy applications. HATS makes your 3270 and 5250 applications available as HTML through the most popular Web browsers, while converting your host screens to a Web look and feel and it also enables you to develop new Web, portal, and rich-client applications. FREE! Go There Now!
| | | | The Eclipse community is constantly working to extend Eclipse's functionality. In this webcast, learn about some of the most important and feature-rich projects under development. From multi-language support to plug-in development, tune in to see what Eclipse is capable of now. FREE! Go There Now!
| | | | Join this webcast to learn how IBM Rational's Functional Testing solution enables you to implement automation your way, at your pace, with your existing staff. In this webcast, you’ll learn how you can eliminate redundancy of manual test scripts, reduce errors, and increase test coverage through test automation. After this presentation you will understand how IBM Rational Functional Testing solution can streamline your manual testing and make test automation easily attainable. FREE! Go There Now!
| | | | As systems increase in complexity, communication between systems and software teams becomes more and more difficult. Now, there’s a way to improve product quality and communication.<br />Read the “Model Driven Systems Development” white paper to see how. Also included in this kit are more educational white papers, customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems.<br /> FREE! Go There Now!
| | | | Join this Rational Talks to You teleconference on December 4 at 1:00 pm ET to discuss how Rational Method Composer can help meet your compliance objectives. Get your questions answered! FREE! Go There Now!
| | | | As organizations integrate software into every aspect of business, they are constantly pressured to deliver faster, better, and cheaper results. Unfortunately, a “dis-integrated” software delivery approach reduces returns while increasing costs. This IBM Rational White Paper shows how Integrated Requirements Management aligns organizations around maximizing value and keeping pace with change. FREE! Go There Now!
| | | | As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications. FREE! Go There Now!
| | | | Download the Rational Application Developer (RAD) v7.5 open beta code and start developing applications for the JEE5 standard which features EJB3.0, JPA, JSF 1.2, JSP 2.1 and Servlet 2.5 standards. When you use this beta you will see how you can increase developer productivity for already existing applications with improved support for refactoring, as well as adding new features to existing applications. In addition, the beta provides tooling for JD Edwards, Oracle, SAP, Siebel and PeopleSoft to improve the developer productivity with these enterprise systems. FREE! Go There Now!
| | | | Learn how you can extend modern application lifecycle management to IBM System z through the IBM Rational Software Delivery Platform (SDP). The Did you say mainframe? e-kit includes podcasts, webcasts, tutorials, white and red papers, demos, and articles designed to help ease the challenges of modernizing your enterprise. This complimentary kit for mainframe developers is a practical, how-to guide for making the most of an existing development environment, including the skills and infrastructure already in place at an established enterprise. FREE! Go There Now!
| | | | You probably have thousands of lines of COBOL code loaded with business intelligence and being used to run your business, along with an army of developers maintaining these applications. Learn how to prepare your applications and developers so you can keep that competitive edge and move to a service-oriented architecture with the IBM Rational Enterprise Modernization solutions. Replay is available for 9 months. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |