Solved

Response.write into a text file

Posted on 2004-08-05
7
669 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

815 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

11 Experts available now in Live!

Get 1:1 Help Now