Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Response.write into a text file

Posted on 2004-08-05
7
Medium Priority
?
675 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
[X]
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
7 Comments
 
LVL 15

Accepted Solution

by:
joeposter649 earned 2000 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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/…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

604 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