Solved

Response.write into a text file

Posted on 2004-08-05
7
667 Views
Last Modified: 2009-12-16
Hi all,
I'm using a dhtml menu that I got from www.milonic.com , I modified the menu.js to go get the menu items from the database. So I renamed menu.js into menu.asp and I added a While loop to go through all the items in my table and populate the menu.
Now this works perfectly except the fact that the menu now takes about 5 to 6 seconds to appear and this bugs me a bit.

So what I thought is that I could do all my Response.write (in the menu.asp file) into a text file that I could name "menu.js" and then in my default page I would include menu.js instead of including menu.asp. But I would have to reload menu.asp each time there are modifications in the database so that it will update the menu.js file...

what do you think about this method? do you have any other methods I could use?

How can I set the Response.write to write into a txt file instead of writing to the screen?
0
Comment
Question by:DesertWarrior
7 Comments
 
LVL 15

Accepted Solution

by:
joeposter649 earned 500 total points
Comment Utility
5 or 6 seconds??? must be a big menu.
Here's how to write to a file...
http://devguru.com/Technologies/vbscript/quickref/textstream_write.html
0
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
But, if you don't do a refresh properly, the user's page may not reflect the updated menu.js file....

FtB
0
 
LVL 2

Expert Comment

by:cheyennejk
Comment Utility
Here is the rough solution. Certain seeting are required for you to write to the server.


example:
Writing an HTML file to the server:




<%

file_being_created= "mypage.html"

' create a file system object
set fso = createobject("scripting.filesystemobject")
Set act = fso.CreateTextFile(file_being_created, true)
' All non repetitive html on top goes here
act.WriteLine("<html><body>")
act.WriteLine(" Hello World!")
act.WriteLine("<body></html>")

' close the object
act.close
%>
</body>
</html>
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 7

Expert Comment

by:Tanglin05
Comment Utility
Even better would be to load your menu items into the ASP application memory- perhaps in a globally available array. Then you only have to make one trip to the database when your application starts-up and all future calls can deal with the array loaded into memory.

This would be significantly faster than either a text file or a database call, though I agree with joeposter that 5-6 seconds is an awful long time for a database menu to load.

Have you tried to optimize your database code? Maybe the connection to your datase (if on a separate server) or your SQL statements are poor. It -should- take less than a second to load a menu of less than 50 items, be it from an Access, SQL, or equivelant database. The very best situation for your menus (if you want them to reflect database updates) would be to NOT implement some other layer of data storage that would have to be separately maintained and updated everytime the database changes.

Let me know if you want help evaluating your db code and I'll be happy to take a look.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
>>the ASP application memory- perhaps in a globally available array.<<

That may not be a good idea. Storing objects or arrays in application variables or session variables can be very resource intensive.

Fritz the Blank
0
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
One way that I have seen this done is as follows:

1) the data required to build your menu is in the database
2) you create the recordset necessary to build your menu
3) you persist the recordset as a static XML file
4) you write a transformation to use the XML file to build your menu

With this approach, you need only do steps 1-3 when the data changes.

FtB
0
 
LVL 5

Author Comment

by:DesertWarrior
Comment Utility
Thanks to all of you guys but my first idea worked perfectly. I implemented an asp file that dynamically creates a .js file... so each time the admin does modifications in the menu, he clicks a Publish button that will call the asp file and it will reWrite the .js file.... it now takes half a second to load my menu that contains about 70 items...

thanks to all of you once again
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now