Solved

Response.write into a text file

Posted on 2004-08-05
7
671 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
ID: 11729631
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
ID: 11729712
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
ID: 11729763
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:Tanglin05
ID: 11732494
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
ID: 11735012
>>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
ID: 11735029
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
ID: 11736726
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
alert(innerHTML); 8 39
Weighted Randomizing 6 33
Obtain data from database .mdb 4 30
Help with Classic ASP - Parameterizing Query 16 24
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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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