Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Servlet writing a .js file

Status
Not open for further replies.

ChrisMcD

Programmer
Nov 8, 2001
5
GB
Righto here is the scene....

Say a bloke is inputing his details name, address etc into a form, he comes to a drop down menu that has his country of origin in it, but he is from a new country eg the independant state of Scotland... doh stuck

What we do is update the db that contains all the countries of the world adding in Scotland. We then have a servlet that takes the info from the db and adds all this to a .js file.

But cause this is a web based application for an intranet and personal details will be added/updated/deleted a few hundred times a day we don't want to have to create this .js file everytime. What we want to do is have the countries0001.js file incremented everytime it is updated and when a newer version is not needed the user will just receive the version that is stored in there browser cache.

So what I have to do is find out;
1) How to create the .js file from a servlet... don't need to know how to update cause each time I'll just create a new one.
2) How to ensure that the client's request will not result each time in a new .js file being created... We are using XML/XSL so what i'll do is just add the new .js file name eg countries0002.js to the xsl <script src=&quot;countries0002.js> tag.

I am gonna be using the this idea for things other than a 'countries' drop-down which will mibbie need updating a few times a day... just incase anybody thinks it's a stupid example.

If anyone has any idea how I can start tackling this problem it would be much appreciated.

Chris
 
all servlets run on the server so to create a .js file all you have to do is
FileOutputStream js = new FileOutputStream( &quot;c:\where\ever\u\want\to\put\the\file\countries000x.js&quot; );

this will create the file. all you have to do is store the name of this file somewhere in your app and call this filename dynamically in your src tag
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top