-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! | <a href="http://zeus.developershed.com/shonuff.php?blackbird=3853&zoneid=442&source=&dest=http%3A%2F%2Fwww.ibm.com%2Fdeveloperworks%2Fspaces%2Fjazz%3FS_TACT%3D105AGY31%26S_CMP%3DDEVSHED&ismap="><img src="http://images.devshed.com/corp/img/news/jazz01.gif" alt="developerWorks Jazz space" align="left"></a>You've heard the buzz about Jazz... want to know more about it from a developer's perspective? Check out the Jazz space on developerWorks. This space is an up-to-date resource for developers, including technical information about Jazz and products built on Jazz, like Rational Team Concert Express. The Jazz space includes content from a wide variety of sources, including links, feeds, and comments from experts. FREE! Go There Now!
| | | | As businesses grow increasingly dependent upon Web applications to provide services to customers, employees and partners, these complex applications become more difficult to secure. Although traditional security solutions protect Internet infrastructure layers, they do not guard against HTTP and HTML attacks. Many organizations that conduct security testing still deploy applications that allow attackers to manipulate their logic and wreak havoc on their business. To mitigate this risk, development and delivery teams must address Web application security throughout the lifecycle, addressing the many layers detailed in this paper. FREE! Go There Now!
| | | | CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP. FREE! Go There Now!
| | | | Learn how to implement a build management system that uses and extends your existing automation technologies. This tutorial shows, step-by-step, how to install and configure IBM Rational Build Forge to manage builds for Jakarta Tomcat from source code. FREE! Go There Now!
| | | | This webcast outlines the best practices that must be instituted to gain the maximum benefit from SOA while maintaining high quality of service. Whether you are deploying new applications or managing and monitoring your existing infrastructure, learn how you can ensure high quality of services with SOA based solutions from IBM. All registrants who attend this live Web Seminar will receive complimentary access to a white paper titled “Maintaining QoS in an SOA Environment”. FREE! Go There Now!
| | | | Discover how Rational tools and best practices for testing can make your job easier. The new Rational Testing eKits provide you with valuable resources – including demos, webcasts, tutorials, and articles – that help you address your specific testing needs across the software lifecycle. Five new eKits are available covering the topics of Requirements and Test Management, Functional Testing, Performance Testing, Code Quality and Embedded Systems, and SOA and Web Services Testing. 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!
| | | | Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time. 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!
| | | | Explore how Rational and WebSphere software enable enterprise documentation in SOA environments. Specifically, a new integration between IBM WebSphere® Business Modeler and IBM Rational® Method Composer software can help technical writers more easily keep enterprise operations manuals in sync with changes that are made to business processes, resulting in more accurate and timely documentation that benefits the entire enterprise. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |