Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Response.write into a text file

Posted on 2004-08-05
7
670 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

791 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